Update of /cvsroot/mahogany/M/src/classes
In directory usw-pr-cvs1:/tmp/cvs-serv6408/src/classes

Modified Files:
        MessageTemplate.cpp 
Log Message:
use implicit quoting with $`...` construct

Index: MessageTemplate.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageTemplate.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -b -u -2 -r1.25 -r1.26
--- MessageTemplate.cpp 4 Mar 2002 18:24:35 -0000       1.25
+++ MessageTemplate.cpp 4 Mar 2002 19:12:25 -0000       1.26
@@ -52,5 +52,10 @@
 // endOfWordMarker) from ppc and adjust ppc pointer to point to the char after
 // the end of word
-static String ExtractWord(const char **ppc, char endOfWordMarker);
+//
+// if quoted is true, we behave as if there were double quotes surrounding the
+// word
+static String ExtractWord(const char **ppc,
+                          char endOfWordMarker,
+                          bool quoted = false);
 
 // ============================================================================
@@ -119,10 +124,19 @@
       // (like $`...` is the same as $(cmd: ...))
       String category;
-      char bracketClose, bracketOpen = *++pc;
+
+      // also, $`...` and $<...< imply implicit quoting as there are almost
+      // surely going to be non-alnum characters inside them (they should
+      // still be quoted explicitly if they contain some special token)
+      bool quoted = false;
+
+      char bracketClose,
+           bracketOpen = *++pc;
       switch ( bracketOpen )
       {
          case '\'':
-            bracketClose = '\'';
+         case '`':
+            bracketClose = bracketOpen;
             category = "cmd";
+            quoted = true;
             break;
 
@@ -130,4 +144,5 @@
             bracketClose = '<';
             category = "file";
+            quoted = true;
             break;
 
@@ -173,5 +188,5 @@
 
       // extract the next word
-      String word = ExtractWord(&pc, bracketClose);
+      String word = ExtractWord(&pc, bracketClose, quoted);
 
       // decide what we've got
@@ -418,5 +433,5 @@
 // ----------------------------------------------------------------------------
 
-String ExtractWord(const char **ppc, char endOfWordMarker)
+String ExtractWord(const char **ppc, char endOfWordMarker, bool forceQuotes)
 {
    const char *pc = *ppc;
@@ -428,6 +443,6 @@
    String word;
    while ( *pc && (*pc != '\n') &&
-         ((quoted && *pc && *pc != '"') ||
-          (isalnum(*pc) && *pc != endOfWordMarker && *pc)) )
+           ((quoted && *pc != '"') ||
+            ((forceQuotes || isalnum(*pc)) && *pc != endOfWordMarker)) )
    {
       if ( quoted && *pc == '\\' )


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to