From: Ben Pfaff Date: Tue, 26 May 2009 03:20:07 +0000 (-0700) Subject: Get rid of uses of MAX_SHORT_STRING in Gnumeric and PostgreSQL readers. X-Git-Tag: v0.7.3~74 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=aaa1996142d111e34e13e490fb299bb94a73ed2f Get rid of uses of MAX_SHORT_STRING in Gnumeric and PostgreSQL readers. MAX_SHORT_STRING is now intended to be an implementation detail of the value code. There is no real reason that the Gnumeric or PostgreSQL readers need to use it, so make them use their own constants instead. --- diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index c3797175..1a6ddc1b 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -60,6 +60,8 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) #include #include +/* Default width of string variables. */ +#define GNUMERIC_DEFAULT_WIDTH 8 static void gnm_file_casereader_destroy (struct casereader *, void *); @@ -476,7 +478,7 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) if (-1 == var_spec [idx].width ) var_spec [idx].width = (gri->asw == -1) ? - ROUND_UP (strlen(text), MAX_SHORT_STRING) : gri->asw; + ROUND_UP (strlen(text), GNUMERIC_DEFAULT_WIDTH) : gri->asw; } free (value); @@ -510,7 +512,7 @@ gnumeric_open_reader (struct gnumeric_read_info *gri, struct dictionary **dict) /* Probably no data exists for this variable, so allocate a default width */ if ( var_spec[i].width == -1 ) - var_spec[i].width = MAX_SHORT_STRING; + var_spec[i].width = GNUMERIC_DEFAULT_WIDTH; if ( ! dict_make_unique_var_name (r->dict, var_spec[i].name, &vstart, name)) diff --git a/src/data/psql-reader.c b/src/data/psql-reader.c index 741bf36e..68ea7e56 100644 --- a/src/data/psql-reader.c +++ b/src/data/psql-reader.c @@ -54,6 +54,9 @@ psql_open_reader (struct psql_read_info *info UNUSED, struct dictionary **dict U #include +/* Default width of string variables. */ +#define PSQL_DEFAULT_WIDTH 8 + /* These macros must be the same as in catalog/pg_types.h from the postgres source */ #define BOOLOID 16 #define BYTEAOID 17 @@ -376,7 +379,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if ( n_tuples > 0 ) length = PQgetlength (qres, 0, i); else - length = MAX_SHORT_STRING; + length = PSQL_DEFAULT_WIDTH; switch (type) { @@ -403,13 +406,13 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) case BPCHAROID: fmt.type = FMT_A; width = (info->str_width == -1) ? - ROUND_UP (length, MAX_SHORT_STRING) : info->str_width; + ROUND_UP (length, PSQL_DEFAULT_WIDTH) : info->str_width; fmt.w = width; fmt.d = 0; break; case BYTEAOID: fmt.type = FMT_AHEX; - width = length > 0 ? length : MAX_SHORT_STRING; + width = length > 0 ? length : PSQL_DEFAULT_WIDTH; fmt.w = width * 2; fmt.d = 0; break; @@ -448,14 +451,14 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) default: msg (MW, _("Unsupported OID %d. SYSMIS values will be inserted."), type); fmt.type = FMT_A; - width = length > 0 ? length : MAX_SHORT_STRING; + width = length > 0 ? length : PSQL_DEFAULT_WIDTH; fmt.w = width ; fmt.d = 0; break; } if ( width == 0 && fmt_is_string (fmt.type)) - fmt.w = width = MAX_SHORT_STRING; + fmt.w = width = PSQL_DEFAULT_WIDTH; var = create_var (r, &fmt, width, PQfname (qres, i), i);