aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/libtinyrad/lstrings.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libtinyrad/lstrings.c')
-rw-r--r--lib/libtinyrad/lstrings.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/lib/libtinyrad/lstrings.c b/lib/libtinyrad/lstrings.c
index e2b6bdf..2c52d71 100644
--- a/lib/libtinyrad/lstrings.c
+++ b/lib/libtinyrad/lstrings.c
@@ -511,6 +511,7 @@ tinyrad_strsplit(
511 char ** argv; 511 char ** argv;
512 char * line; 512 char * line;
513 char * bol; 513 char * bol;
514 char quote;
514 515
515 TinyRadDebugTrace(); 516 TinyRadDebugTrace();
516 517
@@ -534,23 +535,41 @@ tinyrad_strsplit(
534 535
535 for(pos = 0; ((line[pos])); pos++) 536 for(pos = 0; ((line[pos])); pos++)
536 { 537 {
537 if (line[pos] == delim) 538 switch(line[pos])
538 { 539 {
539 argc++; 540 case '"':
540 line[pos] = '\0'; 541 case '\'':
541 if ((rc = tinyrad_strsadd(&argv, bol)) != TRAD_SUCCESS) 542 if (line[pos] != delim)
542 { 543 {
543 free(line); 544 quote = str[pos];
544 tinyrad_strsfree(argv); 545 for(pos += 1; ((line[pos] != '\0') && (line[pos] != quote)); pos++)
545 return(rc); 546 if ( (quote == '"') && (str[pos] == '\\') && (str[pos+1] == '"') )
547 pos++;
548 if (str[pos] != quote)
549 {
550 tinyrad_strsfree(argv);
551 return(TRAD_ESYNTAX);
552 };
553 break;
546 }; 554 };
547 bol = &line[pos+1]; 555
556 default:
557 if (line[pos] == delim)
558 {
559 argc++;
560 line[pos] = '\0';
561 if ((rc = tinyrad_strsadd(&argv, bol)) != TRAD_SUCCESS)
562 {
563 free(line);
564 tinyrad_strsfree(argv);
565 return(rc);
566 };
567 bol = &line[pos+1];
568 };
569 break;
548 }; 570 };
549 }; 571 };
550 572
551// if ( (bol == line) && (!(bol[0])) )
552// return(TRAD_SUCCESS);
553
554 if ((rc = tinyrad_strsadd(&argv, bol)) != TRAD_SUCCESS) 573 if ((rc = tinyrad_strsadd(&argv, bol)) != TRAD_SUCCESS)
555 { 574 {
556 free(line); 575 free(line);