dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog ilasm/ilasm_build.c ilasm/ilasm_...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog ilasm/ilasm_build.c ilasm/ilasm_...
Date: Thu, 26 Jul 2007 19:46:57 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/07/26 19:46:57

Modified files:
        .              : ChangeLog 
        ilasm          : ilasm_build.c ilasm_build.h ilasm_grammar.y 
                         ilasm_scanner.l 

Log message:
        Don't process escape seuences in pathnames.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3481&r2=1.3482
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_build.c?cvsroot=dotgnu-pnet&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_build.h?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_grammar.y?cvsroot=dotgnu-pnet&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/pnet/ilasm/ilasm_scanner.l?cvsroot=dotgnu-pnet&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3481
retrieving revision 1.3482
diff -u -b -r1.3481 -r1.3482
--- ChangeLog   21 Jul 2007 13:05:06 -0000      1.3481
+++ ChangeLog   26 Jul 2007 19:46:56 -0000      1.3482
@@ -1,3 +1,14 @@
+2007-07-26  Klaus Treichel  <address@hidden>
+
+       * ilasm/ilasm_scanner.l, ilasm/ilasm_build.c: Move ParseString from
+       ilasm_scanner.l to ILAsmParseString.c in ilasm_build.c but remove the
+       quotes still in ilasm_scanner.l.
+
+       * ilasm/ilasm_build.h: Add the prototype for ILAsmParseString.
+
+       * ilasm/ilasm_grammar.y: Call ILAsmParseString in the places 
(Identifiers
+       and string constants) where control sequences have to be processed.
+
 2007-07-21  Klaus Treichel  <address@hidden>
 
        * ilasm/ilasm_build.h, ilasm/ilasm_build.h: Add the functions for 
resolving

Index: ilasm/ilasm_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_build.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- ilasm/ilasm_build.c 21 Jul 2007 13:05:07 -0000      1.32
+++ ilasm/ilasm_build.c 26 Jul 2007 19:46:56 -0000      1.33
@@ -229,6 +229,83 @@
        }
 }
 
+/*
+ * Parse a quoted string.
+ */
+ILIntString ILAsmParseString(char *text)
+{
+       char *save = text;
+       char *out = text;
+       int ch, numDigits;
+       static char const escapes[] =
+                       "\007\010cd\033\014ghijklm\012opq\015s\011u\013wxyz";
+
+       /* Collapse escape sequences in the string */
+       while(*text != '\0')
+       {
+               if(*text == '\\')
+               {
+                       ++text;
+                       if(*text == '\0')
+                       {
+                               /* Truncated escape sequence */
+                               break;
+                       }
+                       else if(*text == 'x')
+                       {
+                               /* Hex character */
+                               ++text;
+                               ch = 0;
+                               numDigits = 0;
+                               while(numDigits < 2 && *text != '\0')
+                               {
+                                       if(*text >= '0' && *text <= '9')
+                                               ch = ch * 16 + (*text++ - '0');
+                                       else if(*text >= 'A' && *text <= 'F')
+                                               ch = ch * 16 + (*text++ - 'A' + 
10);
+                                       else if(*text >= 'a' && *text <= 'f')
+                                               ch = ch * 16 + (*text++ - 'a' + 
10);
+                                       else
+                                               break;
+                                       ++numDigits;
+                               }
+                               *out++ = (char)ch;
+                       }
+                       else if(*text >= 'a' && *text <= 'z')
+                       {
+                               /* Ordinary C-style escape */
+                               *out++ = escapes[*text - 'a'];
+                               ++text;
+                       }
+                       else if(*text >= '0' && *text <= '7')
+                       {
+                               /* Octal character */
+                               numDigits = 1;
+                               ch = *text++ - '0';
+                               while(numDigits < 3 && *text >= '0' && *text <= 
'7')
+                               {
+                                       ch = ch * 8 + (*text++ - '0');
+                                       ++numDigits;
+                               }
+                               *out++ = (char)ch;
+                       }
+                       else
+                       {
+                               /* Normal escaped character */
+                               *out++ = *text++;
+                       }
+               }
+               else
+               {
+                       /* Normal character */
+                       *out++ = *text++;
+               }
+       }
+
+       /* Internalise the string */
+       return ILInternString(save, (int)(out - save));
+}
+
 void ILAsmSplitName(const char *str, int len, const char **name,
                                        const char **namespace)
 {

Index: ilasm/ilasm_build.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_build.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- ilasm/ilasm_build.h 21 Jul 2007 13:05:07 -0000      1.16
+++ ilasm/ilasm_build.h 26 Jul 2007 19:46:57 -0000      1.17
@@ -144,6 +144,11 @@
 void ILAsmBuildPopScope(void);
 
 /*
+ * Parse a quoted string.
+ */
+ILIntString ILAsmParseString(char *text);
+
+/*
  * Split a string into name and namespace.
  */
 void ILAsmSplitName(const char *str, int len, const char **name,

Index: ilasm/ilasm_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_grammar.y,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- ilasm/ilasm_grammar.y       21 Jul 2007 13:05:07 -0000      1.49
+++ ilasm/ilasm_grammar.y       26 Jul 2007 19:46:57 -0000      1.50
@@ -686,6 +686,7 @@
        ILInt16                 genParAttrib;
        ILIntString             strValue;
        ILDouble                real;
+       char               *quoteString;
        struct {
                ILUInt8         fbytes[4];
                ILUInt8         dbytes[8];
@@ -1037,7 +1038,8 @@
  * Define the yylval types of the various non-terminals.
  */
 %type <integer>                INTEGER_CONSTANT HEX_BYTE
-%type <strValue>       SQUOTE_STRING DQUOTE_STRING ComposedString NativeType
+%type <quoteString> DQUOTE_STRING SQUOTE_STRING
+%type <strValue>       ComposedString NativeType
 %type <strValue>       QualifiedName Identifier MethodName IDENTIFIER Bytes
 %type <strValue>       SlashedName DOT_IDENTIFIER AssemblyName
 %type <real>           FLOAT_CONSTANT
@@ -1178,7 +1180,7 @@
 
 Identifier
        : IDENTIFIER    { $$ = $1; }
-       | SQUOTE_STRING { $$ = $1; }
+       | SQUOTE_STRING { $$ = ILAsmParseString($1); }
        ;
 
 Integer32
@@ -1293,9 +1295,11 @@
        ;
 
 ComposedString
-       : DQUOTE_STRING { $$ = $1; }
+       : DQUOTE_STRING                                 {
+                               $$ = ILAsmParseString($1);
+                       }
        | ComposedString '+' DQUOTE_STRING {
-                               $$ = ILInternAppendedString($1, $3);
+                               $$ = ILInternAppendedString($1, 
ILAsmParseString($3));
                        }
        ;
 
@@ -3596,16 +3600,20 @@
 
 ExternalSourceSpecification
        : D_LINE INTEGER_CONSTANT SQUOTE_STRING {
-                               ILAsmDebugLine((ILUInt32)($2), 0, $3.string);
+                               ILAsmDebugLine((ILUInt32)($2), 0,
+                                                          ILInternString($3, 
-1).string);
                        }
        | D_LINE INTEGER_CONSTANT ':' INTEGER_CONSTANT SQUOTE_STRING    {
-                               ILAsmDebugLine((ILUInt32)($2), (ILUInt32)($4), 
$5.string);
+                               ILAsmDebugLine((ILUInt32)($2), (ILUInt32)($4),
+                                                          ILInternString($5, 
-1).string);
                        }
        | D_LINE INTEGER_CONSTANT DQUOTE_STRING {
-                               ILAsmDebugLine((ILUInt32)($2), 0, $3.string);
+                               ILAsmDebugLine((ILUInt32)($2), 0,
+                                                          ILInternString($3, 
-1).string);
                        }
        | D_LINE INTEGER_CONSTANT ':' INTEGER_CONSTANT DQUOTE_STRING    {
-                               ILAsmDebugLine((ILUInt32)($2), (ILUInt32)($4), 
$5.string);
+                               ILAsmDebugLine((ILUInt32)($2), (ILUInt32)($4),
+                                                          ILInternString($5, 
-1).string);
                        }
        | D_LINE INTEGER_CONSTANT       {
                                ILAsmDebugLine((ILUInt32)($2), 0, 
ILAsmDebugLastFile);
@@ -4123,14 +4131,14 @@
 SecurityDeclaration
        : D_PERMISSION SecurityAction ClassName '(' NameValuePairs ')'
        | D_CAPABILITY SecurityAction SQUOTE_STRING     {
-                               ILIntString unicode = PackUnicodeString($3);
+                               ILIntString unicode = 
PackUnicodeString(ILAsmParseString($3));
                                ILAsmSecurityCreate($2, unicode.string, 
unicode.len);
                        }
        | D_CAPABILITY SecurityAction '=' Bytes         {
                                ILAsmSecurityCreate($2, $4.string, $4.len);
                        }
        | D_PERMISSIONSET SecurityAction SQUOTE_STRING  {
-                               ILIntString unicode = PackUnicodeString($3);
+                               ILIntString unicode = 
PackUnicodeString(ILAsmParseString($3));
                                ILAsmSecurityCreate($2, unicode.string, 
unicode.len);
                        }
        | D_PERMISSIONSET SecurityAction '=' Bytes      {

Index: ilasm/ilasm_scanner.l
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ilasm/ilasm_scanner.l,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- ilasm/ilasm_scanner.l       21 Jul 2007 13:05:07 -0000      1.17
+++ ilasm/ilasm_scanner.l       26 Jul 2007 19:46:57 -0000      1.18
@@ -112,87 +112,6 @@
 }
 
 /*
- * Parse a quoted string.
- */
-static ILIntString ParseString(char *text, int *len)
-{
-       char *save = text;
-       char *out = text;
-       int ch, numDigits;
-       static char const escapes[] =
-                       "\007\010cd\033\014ghijklm\012opq\015s\011u\013wxyz";
-
-       /* Remove the quote characters */
-       ++text;
-       text[strlen(text) - 1] = '\0';
-
-       /* Collapse escape sequences in the string */
-       while(*text != '\0')
-       {
-               if(*text == '\\')
-               {
-                       ++text;
-                       if(*text == '\0')
-                       {
-                               /* Truncated escape sequence */
-                               break;
-                       }
-                       else if(*text == 'x')
-                       {
-                               /* Hex character */
-                               ++text;
-                               ch = 0;
-                               numDigits = 0;
-                               while(numDigits < 2 && *text != '\0')
-                               {
-                                       if(*text >= '0' && *text <= '9')
-                                               ch = ch * 16 + (*text++ - '0');
-                                       else if(*text >= 'A' && *text <= 'F')
-                                               ch = ch * 16 + (*text++ - 'A' + 
10);
-                                       else if(*text >= 'a' && *text <= 'f')
-                                               ch = ch * 16 + (*text++ - 'a' + 
10);
-                                       else
-                                               break;
-                                       ++numDigits;
-                               }
-                               *out++ = (char)ch;
-                       }
-                       else if(*text >= 'a' && *text <= 'z')
-                       {
-                               /* Ordinary C-style escape */
-                               *out++ = escapes[*text - 'a'];
-                               ++text;
-                       }
-                       else if(*text >= '0' && *text <= '7')
-                       {
-                               /* Octal character */
-                               numDigits = 1;
-                               ch = *text++ - '0';
-                               while(numDigits < 3 && *text >= '0' && *text <= 
'7')
-                               {
-                                       ch = ch * 8 + (*text++ - '0');
-                                       ++numDigits;
-                               }
-                               *out++ = (char)ch;
-                       }
-                       else
-                       {
-                               /* Normal escaped character */
-                               *out++ = *text++;
-                       }
-               }
-               else
-               {
-                       /* Normal character */
-                       *out++ = *text++;
-               }
-       }
-
-       /* Internalise the string */
-       return ILInternString(save, (int)(out - save));
-}
-
-/*
  * Helper macros for returning opcodes of various types.
  */
 #define        OPCODE_NONE(name)       yylval.opcode = IL_OP_##name; \
@@ -1084,11 +1003,17 @@
                }
 
 <INITIAL,JAVAMODE>'(\\.|[^\\'])*'              {
-                       yylval.strValue = ParseString(yytext, 
&(yylval.strValue.len));
+                       /* Remove the quote characters */
+                       char *str = yytext + 1;
+                       str[strlen(str) - 1] = '\0';
+                       yylval.quoteString = str;
                        return SQUOTE_STRING;
                }
 <INITIAL,JAVAMODE>\"(\\.|[^\\"])*\"            {
-                       yylval.strValue = ParseString(yytext, 
&(yylval.strValue.len));
+                       /* Remove the quote characters */
+                       char *str = yytext + 1;
+                       str[strlen(str) - 1] = '\0';
+                       yylval.quoteString = str;
                        return DQUOTE_STRING;
                }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]