Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/lib


Modified Files:
        libevfs.c 


Log Message:
* Fix for 'left over' tokens on the end of lex'ed strings

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/lib/libevfs.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- libevfs.c   20 Nov 2005 23:23:36 -0000      1.25
+++ libevfs.c   28 Nov 2005 08:27:16 -0000      1.26
@@ -168,7 +168,8 @@
        Ecore_List* reserved = ecore_dlist_new();
        Ecore_List* plugin = ecore_dlist_new();
        
-       char* dup_uri = strdup(uri);
+       char* dup_uri = malloc(strlen(uri) + 2);
+       
        /*dup_uri = realloc(dup_uri, strlen(uri)+2); 
        strcat(dup_uri," ");*/
        
@@ -183,6 +184,8 @@
        char c='1';
        int len=0;
 
+       snprintf(dup_uri, strlen(uri)+1, "%s ", uri);
+
        ecore_list_append(plugin, "smb"); /*Shift these to register when a 
plugin registers*/
        ecore_list_append(plugin, "posix");
        ecore_list_append(plugin, "tar");
@@ -198,7 +201,7 @@
        ecore_list_append(reserved, "#");
        ecore_list_append(reserved, ";");
 
-       //printf ("Lexing '%s'\n", dup_uri);
+       printf ("Lexing '%s'\n", dup_uri);
        //printf("Strlen(uri): %d\n", strlen(uri));
 
        while (j <= strlen(dup_uri)) {
@@ -207,7 +210,7 @@
                
                strncpy(tmp_tok, l_uri, 3);
                tmp_tok[3] = '\0';
-               /*printf("Current token is: '%s'\n", tmp_tok);*/
+               //printf("Current token is: '%s'\n", tmp_tok);
                        
                /*Check if it's an operator*/
                ecore_list_goto_first(reserved);
@@ -218,11 +221,12 @@
                                len=strlen(cmp);
                                i = 0;
 
-                               /*printf("L_URI becomes '%s'\n", l_uri);*/
+                               //printf("L_URI becomes '%s'\n", l_uri);
                                token = NEW(evfs_uri_token);
                                token->token_s = strdup(cmp);
                                token->type = EVFS_URI_TOKEN_OPERATOR;
                                ecore_dlist_append(tokens, token);
+                               bzero(tmp_tok, 255);
 
                                goto cont_loop;
                        }
@@ -231,7 +235,7 @@
                /*Check if it's a keyword*/
                strncpy(tmp_tok, l_uri, i);
                tmp_tok[i] = '\0';
-               /*printf("Current token (keyword match) is: '%s'\n", tmp_tok);*/
+               //printf("Current token (keyword match) is: '%s'\n", tmp_tok);
        
                ecore_list_goto_first(plugin);
                while ( (cmp = ecore_list_next(plugin))) {
@@ -240,12 +244,13 @@
 
                                l_uri += strlen(cmp);                   
                                i = 0;
-                               /*printf("L_URI becomes '%s'\n", l_uri);*/
+                               //printf("L_URI becomes '%s'\n", l_uri);
 
                                token = NEW(evfs_uri_token);
                                token->token_s = strdup(cmp);
                                token->type = EVFS_URI_TOKEN_KEYWORD;
                                ecore_dlist_append(tokens, token); 
+                               bzero(tmp_tok,255);
                                
                                goto cont_loop; /*Eww goto - but we're in two 
while loops*/
                        }
@@ -260,13 +265,14 @@
                        
                        tmp_tok[i] = '\0';
                        
-                       /*printf ("Looks like a string..\n");*/
+                       //printf ("Looks like a string..\n");
                        //printf("Found string: '%s', i is %d, j is %d, 
strlen(dup_uri) is %d\n", tmp_tok,i,j,strlen(dup_uri));
                
                        token = NEW(evfs_uri_token);
                        token->token_s = strdup(tmp_tok);
                        token->type = EVFS_URI_TOKEN_STRING;                    
                        ecore_dlist_append(tokens, token);
+                       bzero(tmp_tok, 255);
                        
                        l_uri += i;
                        i=0;
@@ -288,6 +294,19 @@
        }
 
        lexer_done:
+
+       /*This is really evil - we assume the last token is a string*/
+       /*There is something wrong with the offsets above if this is
+        * the case*/
+       if (strlen(tmp_tok) > 0) {
+               token = NEW(evfs_uri_token);
+               token->token_s = strdup(tmp_tok);
+               token->type = EVFS_URI_TOKEN_STRING;                    
+               ecore_dlist_append(tokens, token);
+       }               
+
+       
+       
        free(dup_uri);
        return tokens;  
 }




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to