const-correctness and query.c.diff rebase
Jim Meyering
jim at meyering.net
Mon Oct 11 21:49:01 UTC 2010
FYI, just pushed:
>From c9e88edd5d31c8b3465af9558d424b329d483812 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Mon, 11 Oct 2010 22:47:39 +0200
Subject: [PATCH 1/2] query.c.diff: regenerate to avoid offsets
---
query.c.diff | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/query.c.diff b/query.c.diff
index 22b8f7e..a63acfa 100644
--- a/query.c.diff
+++ b/query.c.diff
@@ -1,6 +1,6 @@
---- query-orig.c 2010-10-01 12:56:20.000000000 -0400
-+++ query.c 2010-10-01 12:56:20.000000000 -0400
-@@ -538,7 +538,7 @@ YY_LOCAL(int) yyrefill(void)
+--- query-orig.c 2010-10-11 22:45:55.906022513 +0200
++++ query.c 2010-10-11 22:45:55.909022417 +0200
+@@ -582,7 +582,7 @@ YY_LOCAL(int) yyrefill(void)
while (yybuflen - yypos < 512)
{
yybuflen *= 2;
@@ -9,7 +9,7 @@
}
YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos));
if (!yyn) return 0;
-@@ -603,7 +603,7 @@ YY_LOCAL(void) yyDo(yyaction action, int
+@@ -647,7 +647,7 @@ YY_LOCAL(void) yyDo(yyaction action, int
while (yythunkpos >= yythunkslen)
{
yythunkslen *= 2;
@@ -18,7 +18,7 @@
}
yythunks[yythunkpos].begin= begin;
yythunks[yythunkpos].end= end;
-@@ -621,7 +621,7 @@ YY_LOCAL(int) yyText(int begin, int end)
+@@ -665,7 +665,7 @@ YY_LOCAL(int) yyText(int begin, int end)
while (yytextlen < (yyleng - 1))
{
yytextlen *= 2;
@@ -27,7 +27,7 @@
}
memcpy(yytext, yybuf + begin, yyleng);
}
-@@ -1159,13 +1159,13 @@ YY_PARSE(int) YYPARSEFROM(yyrule yystart
+@@ -1203,13 +1203,13 @@ YY_PARSE(int) YYPARSEFROM(yyrule yystart
if (!yybuflen)
{
yybuflen= 1024;
--
1.7.3.1.104.gc752e
>From e085aab9a4664efad596e4177443c94125fd0aac Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Mon, 11 Oct 2010 22:50:57 +0200
Subject: [PATCH 2/2] template: const correctness
* template.c (xml_format, json_format): Declare const.
(xml_obj_header, xml_obj_entry, xml_obj_footer): Likewise.
Adjust all uses of ctx->format accordingly.
* template.h [struct tmpl_format_t] (format): Declare const.
---
template.c | 34 +++++++++++++++++-----------------
template.h | 2 +-
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/template.c b/template.c
index 6fe2edd..a7f1cca 100644
--- a/template.c
+++ b/template.c
@@ -71,23 +71,23 @@ static const char xml_list_footer[] = "\
</objects>\n\
";
-static char xml_obj_header[] = "\
+static const char xml_obj_header[] = "\
<object>\n\
<object_body path=\"http://%s/%s/%s/body\"/>\n\
<object_attr_list path=\"http://%s/%s/%s/attrs\"/>\
";
-static char xml_obj_entry[] = "\
+static const char xml_obj_entry[] = "\
\n\
<object_attr name=\"%s\" path=\"http:/%s/%s/%s/attr_%s\"\
";
-static char xml_obj_footer[] = "\
+static const char xml_obj_footer[] = "\
\n\
</object>\n\
";
-tmpl_format_t xml_format = {
+static const tmpl_format_t xml_format = {
.root_header = xml_root_header,
.root_entry = xml_root_entry,
.root_footer = xml_root_footer,
@@ -178,7 +178,7 @@ static char json_obj_footer[] = "\
}\n\
";
-tmpl_format_t json_format = {
+static const tmpl_format_t json_format = {
.root_header = json_root_header,
.root_entry = json_root_entry,
.root_footer = json_root_footer,
@@ -215,8 +215,8 @@ tmpl_get_ctx (const char *type)
int
tmpl_root_header (tmpl_ctx_t *ctx, const char *name, const char *version)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->root_header,
name,version);
@@ -231,8 +231,8 @@ tmpl_root_header (tmpl_ctx_t *ctx, const char *name, const char *version)
int
tmpl_root_entry (tmpl_ctx_t *ctx, const char *rel, const char *link)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->root_entry,
rel, ctx->base, link);
@@ -270,8 +270,8 @@ tmpl_prov_entry (tmpl_ctx_t *ctx,
const char *host, int port,
const char *user, const char *pass)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->prov_entry,
name, type, host, port, user, pass);
@@ -306,8 +306,8 @@ tmpl_list_header (tmpl_ctx_t *ctx)
int
tmpl_list_entry (tmpl_ctx_t *ctx, const char *bucket, const char *key)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->list_entry,bucket,key);
if (size >= TMPL_BUF_SIZE) {
@@ -334,8 +334,8 @@ tmpl_list_footer (tmpl_ctx_t *ctx)
int
tmpl_obj_header (tmpl_ctx_t *ctx, const char *bucket, const char *key)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->obj_header,
ctx->base, bucket, key, /* once for the body... */
@@ -353,8 +353,8 @@ int
tmpl_obj_entry (tmpl_ctx_t *ctx, const char *bucket, const char *key,
const char *attr)
{
- int size;
- tmpl_format_t *fmt = ctx->format;
+ int size;
+ const tmpl_format_t *fmt = ctx->format;
size = snprintf(ctx->raw_buf,TMPL_BUF_SIZE,fmt->obj_entry,
attr, ctx->base, bucket, key, attr);
diff --git a/template.h b/template.h
index 5de47d1..9b7912e 100644
--- a/template.h
+++ b/template.h
@@ -35,7 +35,7 @@ typedef struct {
} tmpl_format_t;
typedef struct {
- tmpl_format_t *format;
+ const tmpl_format_t *format;
const char *base;
unsigned int index;
char raw_buf[TMPL_BUF_SIZE];
--
1.7.3.1.104.gc752e
More information about the iwhd-devel
mailing list