Advertisement
rfmonk

example_nonreentrant_function.c

Jul 23rd, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. scan_string (char *s)
  2. {  
  3.      int length = strlen (s);
  4.      /* Initialize shift state. */
  5.      mblen (NULL, 0);
  6.      
  7.      while (1)
  8.      {    
  9.          int thischar = mblen (s, length);
  10.          /* Deal with end of string and invalid characters.  */
  11.          if (thischar == 0)
  12.              break;
  13.          if (thischar == -1)
  14.          {  
  15.              error ("invalid multibyte characters.");
  16.              break;
  17.          }  
  18.          /* Advance past this character.  */
  19.          a += thischar;
  20.          length -= thischar;
  21.      }  
  22.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement