/[pspp]/pspp/src/recode.c
ViewVC logotype

Diff of /pspp/src/recode.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by blp, Sun Aug 7 04:39:28 2005 UTC revision 1.26 by blp, Mon Oct 24 02:51:31 2005 UTC
# Line 75  struct rcd_var Line 75  struct rcd_var
75      union value sysmis;         /* Coding for SYSMIS (if src is numeric). */      union value sysmis;         /* Coding for SYSMIS (if src is numeric). */
76    
77      struct coding *map;         /* Coding for other values. */      struct coding *map;         /* Coding for other values. */
78      int nmap, mmap;             /* Length of map, max capacity of map. */      size_t nmap, mmap;          /* Length of map, max capacity of map. */
79    };    };
80    
81  /* RECODE transformation. */  /* RECODE transformation. */
# Line 118  static double convert_to_double (const c Line 118  static double convert_to_double (const c
118  int  int
119  cmd_recode (void)  cmd_recode (void)
120  {  {
121    int i;    size_t i;
122    
123    /* Transformation that we're constructing. */    /* Transformation that we're constructing. */
124    struct rcd_var *rcd;    struct rcd_var *rcd;
# Line 145  cmd_recode (void) Line 145  cmd_recode (void)
145    
146    /* Variables in the current part of the recoding. */    /* Variables in the current part of the recoding. */
147    struct variable **v;    struct variable **v;
148    int nv;    size_t nv;
149    
150    /* Parses each specification between slashes. */    /* Parses each specification between slashes. */
151    head = rcd = xmalloc (sizeof *rcd);    head = rcd = xmalloc (sizeof *rcd);
# Line 190  cmd_recode (void) Line 190  cmd_recode (void)
190        for (;;)        for (;;)
191          {          {
192            /* Get the input value (before the `='). */            /* Get the input value (before the `='). */
193            int mark = rcd->nmap;            size_t mark = rcd->nmap;
194            int code = parse_src_spec (rcd, type, max_src_width);            int code = parse_src_spec (rcd, type, max_src_width);
195            if (!code)            if (!code)
196              goto lossage;              goto lossage;
# Line 271  cmd_recode (void) Line 271  cmd_recode (void)
271        if (lex_match_id ("INTO"))        if (lex_match_id ("INTO"))
272          {          {
273            char **names;            char **names;
274            int nnames;            size_t nnames;
275    
276            int success = 0;            int success = 0;
277    
# Line 283  cmd_recode (void) Line 283  cmd_recode (void)
283                for (i = 0; i < nnames; i++)                for (i = 0; i < nnames; i++)
284                  free (names[i]);                  free (names[i]);
285                free (names);                free (names);
286                msg (SE, _("%d variable(s) cannot be recoded into "                msg (SE, _("%u variable(s) cannot be recoded into "
287                           "%d variable(s).  Specify the same number "                           "%u variable(s).  Specify the same number "
288                           "of variables as input and output variables."),                           "of variables as input and output variables."),
289                     nv, nnames);                     (unsigned) nv, (unsigned) nnames);
290                goto lossage;                goto lossage;
291              }              }
292    
# Line 298  cmd_recode (void) Line 298  cmd_recode (void)
298                  if (!v)                  if (!v)
299                    {                    {
300                      msg (SE, _("There is no string variable named "                      msg (SE, _("There is no string variable named "
301                           "%s.  (All string variables specified "                                 "%s.  (All string variables specified "
302                           "on INTO must already exist.  Use the "                                 "on INTO must already exist.  Use the "
303                           "STRING command to create a string "                                 "STRING command to create a string "
304                           "variable.)"), names[i]);                                 "variable.)"),
305                             names[i]);
306                      goto INTO_fail;                      goto INTO_fail;
307                    }                    }
308                  if (v->type != ALPHA)                  if (v->type != ALPHA)
309                    {                    {
310                      msg (SE, _("Type mismatch between input and output "                      msg (SE, _("Type mismatch between input and output "
311                           "variables.  Output variable %s is not "                                 "variables.  Output variable %s is not "
312                           "a string variable, but all the input "                                 "a string variable, but all the input "
313                           "variables are string variables."), v->name);                                 "variables are string variables."),
314                             v->name);
315                      goto INTO_fail;                      goto INTO_fail;
316                    }                    }
317                  if (v->width > (int) max_dst_width)                  if (v->width > (int) max_dst_width)
# Line 519  parse_src_spec (struct rcd_var * rcd, in Line 521  parse_src_spec (struct rcd_var * rcd, in
521    
522    for (;;)    for (;;)
523      {      {
524        if (rcd->nmap >= rcd->mmap - 1)        if (rcd->nmap + 1 >= rcd->mmap)
525          {          {
526            rcd->mmap += 16;            rcd->mmap += 16;
527            rcd->map = xrealloc (rcd->map, rcd->mmap * sizeof *rcd->map);            rcd->map = xrealloc (rcd->map, rcd->mmap * sizeof *rcd->map);
# Line 649  parse_src_spec (struct rcd_var * rcd, in Line 651  parse_src_spec (struct rcd_var * rcd, in
651  static void  static void
652  recode_trns_free (struct trns_header * t)  recode_trns_free (struct trns_header * t)
653  {  {
654    int i;    size_t i;
655    struct rcd_var *head, *next;    struct rcd_var *head, *next;
656    
657    head = ((struct recode_trns *) t)->codings;    head = ((struct recode_trns *) t)->codings;
# Line 834  static long int Line 836  static long int
836  string_to_long (const char *nptr, int width, const char **endptr)  string_to_long (const char *nptr, int width, const char **endptr)
837  {  {
838    int negative;    int negative;
839    register unsigned long int cutoff;    unsigned long int cutoff;
840    register unsigned int cutlim;    unsigned int cutlim;
841    register unsigned long int i;    unsigned long int i;
842    register const char *s;    const char *s;
843    register unsigned char c;    unsigned char c;
844    const char *save;    const char *save;
845    
846    s = nptr;    s = nptr;
# Line 909  string_to_long (const char *nptr, int wi Line 911  string_to_long (const char *nptr, int wi
911  static double  static double
912  convert_to_double (const char *s, int width)  convert_to_double (const char *s, int width)
913  {  {
914    register const char *end = &s[width];    const char *end = &s[width];
915    
916    short int sign;    short int sign;
917    

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26