Branch: Tag:

2003-02-11

2003-02-11 16:16:01 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed typo in sscanf("%O") handling.
Improved field length handling in sscanf("%O").

Rev: src/opcodes.c:1.138

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: opcodes.c,v 1.137 2003/02/11 15:22:28 mirar Exp $ + || $Id: opcodes.c,v 1.138 2003/02/11 16:16:01 grubba Exp $   */      #include "global.h"
30:      #define sp Pike_sp    - RCSID("$Id: opcodes.c,v 1.137 2003/02/11 15:22:28 mirar Exp $"); + RCSID("$Id: opcodes.c,v 1.138 2003/02/11 16:16:01 grubba Exp $");      void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)   {
863:    * helper functions for sscanf %O    */    - static PMOD_EXPORT int pcharp_extract_char_const(PCHARP str, + static int pcharp_extract_char_const(PCHARP str,    PCHARP *dstr,    ptrdiff_t maxlength,    ptrdiff_t *dmaxlength)
871:    int c;       *dstr=str; -  maxlength--; -  *dmaxlength=maxlength; +  *dmaxlength=maxlength-1;    -  switch (c=EXTRACT_PCHARP(str)) +  /* use of macros to keep similar to lexer.h: char_const */ + #define LOOK() (maxlength?INDEX_PCHARP(str,1):0) + #define GETC() (maxlength?(INC_PCHARP(str,1),maxlength--,EXTRACT_PCHARP(str)):0) +  +  switch (c=GETC())    {    case 0:    *dmaxlength=maxlength+1;
883:    case '\\':    return '\\';    -  /* use of macros to keep similar to lexer.h: char_const */ - #define LOOK() (maxlength?INDEX_PCHARP(str,1):0) - #define GETC() (INC_PCHARP(str,1),INDEX_PCHARP(str,0)) -  +     case '0': case '1': case '2': case '3':    case '4': case '5': case '6': case '7':    c-='0';
952:    return c;   }    - static PMOD_EXPORT int pcharp_to_svalue_procento(struct svalue *r, + static int pcharp_to_svalue_percent_o(struct svalue *r,    PCHARP str,    PCHARP *dstr,    ptrdiff_t maxlength)
1971:    INPUT_SHIFT)(input+e,eye-e); \    break; \    \ -  case 'O': \ -  { \ +  case 'O': \ +  { \    PIKE_CONCAT(p_wchar, INPUT_SHIFT) *t; \ -  PCHARP tmp; \ -  if(eye>=input_len) \ -  { \ -  chars_matched[0]=eye; \ -  return matches; \ -  } \ +  PCHARP tmp; \ +  if(eye>=input_len) \ +  { \ +  chars_matched[0]=eye; \ +  return matches; \ +  } \    \ -  pcharp_to_svalue_procento(&sval, \ -  MKPCHARP(input+eye,INPUT_SHIFT), \ -  &tmp, \ +  pcharp_to_svalue_percent_o(&sval, \ +  MKPCHARP(input+eye,INPUT_SHIFT), \ +  &tmp, \    field_length); \ -  t=(PIKE_CONCAT(p_wchar, INPUT_SHIFT) *)tmp.ptr; \ -  if(input + eye == t) \ -  { \ -  chars_matched[0]=eye; \ -  return matches; \ -  } \ -  eye=t-input; \ +  t=(PIKE_CONCAT(p_wchar, INPUT_SHIFT) *)tmp.ptr; \ +  if(input + eye == t) \ +  { \ +  chars_matched[0]=eye; \ +  return matches; \ +  } \ +  eye=t-input; \    \ -  break; \ -  } \ +  break; \ +  } \    \    case 'n': \    sval.type=T_INT; \