- Timestamp:
- Jan 8, 2006, 10:13:03 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_database.c
r12 r13 1438 1438 attr_tab[i].attr = malloc (j+1); /* only once */ 1439 1439 if (NULL == attr_tab[i].attr) 1440 SL_RETURN (NULL, _("sh_database_parse"));1440 return; 1441 1441 for (k = 0; k < j; ++k) 1442 1442 attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE; … … 1503 1503 escp = (escp == 1) ? 0 : 1; 1504 1504 } 1505 else if (*p == '\'' && escp == 0) 1506 { 1507 retv = S_FALSE; 1508 } 1509 else if (*p == '\"' && escp == 0) 1505 else if ((*p == '\'' || *p == '\"') && escp == 0) 1510 1506 { 1511 1507 retv = S_FALSE; … … 1573 1569 parse: 1574 1570 1575 while ( (p != NULL) && (*p == ' ' || *p == '>'))1571 while (*p == ' ' || *p == '>') 1576 1572 ++p; 1577 1573 1578 if ( !p ||*p == '\0')1574 if (*p == '\0') 1579 1575 SL_RETURN(NULL, _("sh_database_parse")); 1580 1576 … … 1673 1669 } 1674 1670 } 1675 ++i;1676 1671 } 1677 1672 -
trunk/src/sh_utils.c
r12 r13 245 245 246 246 247 /* returned string must be free'd by caller 247 /* returned string must be free'd by caller. 248 248 */ 249 249 char * sh_util_formatted (const char * formatt, st_format * ftab) … … 260 260 time_t inpp; 261 261 262 char * clist[16]; 262 char * clist[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 263 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; 263 264 int nn = 0; 264 265 265 266 SL_ENTER(_("sh_util_formatted")); 266 267 267 if (formatt == NULL || ftab == NULL )268 if (formatt == NULL || ftab == NULL || *formatt == '\0') 268 269 SL_RETURN(NULL, _("sh_util_formatted")); 269 270 … … 271 272 */ 272 273 size = sl_strlen(formatt); 273 if (size > 0) 274 { 275 fmt = (char *) SH_ALLOC(size + 1); 276 (void) sl_strlcpy(fmt, formatt, size + 1); 277 } 278 else 279 SL_RETURN(NULL, _("sh_util_formatted")); 274 275 fmt = (char *) SH_ALLOC(size + 1); 276 (void) sl_strlcpy(fmt, formatt, size + 1); 280 277 281 278 p = fmt; 282 279 283 280 j = 0; 284 while (ftab[j].fchar != '\0') 285 { 286 if (ftab[j].type != S_FMT_STRING) 287 ftab[j].data_str = NULL; 288 ++j; 289 } 290 291 for (j = 0; j < 16; ++j) 292 clist[j] = NULL; 293 281 while (ftab[j].fchar != '\0') { 282 if (ftab[j].type != S_FMT_STRING) 283 ftab[j].data_str = NULL; 284 ++j; 285 } 286 294 287 while (p != NULL && *p != '\0' && NULL != (q = strchr(p, '%'))) 295 288 { … … 324 317 i = 1; 325 318 326 if (ftab[j].type == S_FMT_STRING) 319 switch(ftab[j].type) { 320 321 case S_FMT_STRING: 327 322 { 328 323 isiz = sl_strlen(ftab[j].data_str); … … 335 330 else 336 331 *q = '%'; 337 break;332 goto endsrch; 338 333 } 339 else if (ftab[j].type == S_FMT_ULONG) 334 break; 335 336 case S_FMT_ULONG: 340 337 { 341 338 ftab[j].data_str = (char *) SH_ALLOC(64); … … 353 350 else 354 351 *q = '%'; 355 break;352 goto endsrch; 356 353 } 357 else if (ftab[j].type == S_FMT_LONG) 354 break; 355 356 case S_FMT_LONG: 358 357 { 359 358 ftab[j].data_str = (char *) SH_ALLOC(64); … … 371 370 else 372 371 *q = '%'; 373 break;372 goto endsrch; 374 373 } 375 else if (ftab[j].type == S_FMT_TIME) 374 break; 375 376 case S_FMT_TIME: 376 377 { 377 378 ftab[j].data_str = (char *) SH_ALLOC(64); … … 401 402 else 402 403 *q = '%'; 403 break;404 goto endsrch; 404 405 } 406 break; 407 408 default: 409 /* do nothing */; 410 } 405 411 406 412 } 407 else 408 ++j; 409 } 413 ++j; 414 } 415 416 endsrch: 417 418 p = q; 410 419 411 420 /* -- not found -- */ … … 413 422 { 414 423 *q = '%'; 415 p = q;416 424 ++p; 417 425 } 418 else 419 { 420 p = q; 421 } 426 422 427 } 423 428 … … 443 448 */ 444 449 j = 0; 445 while (ftab[j].fchar != '\0') 446 { 447 if (ftab[j].type != S_FMT_STRING && ftab[j].data_str != NULL) 448 SH_FREE(ftab[j].data_str); 449 ++j; 450 } 450 while (ftab[j].fchar != '\0') { 451 if (ftab[j].type != S_FMT_STRING && ftab[j].data_str != NULL) 452 SH_FREE(ftab[j].data_str); 453 ++j; 454 } 451 455 SH_FREE(fmt); 452 456 … … 474 478 { 475 479 int i = 0, j, k, l = 0; 480 char c; 481 482 #define SH_HEXCHAR(x, y) \ 483 c = (x); \ 484 if ( c >= '0' && c <= '9' ) \ 485 y = c - '0'; \ 486 else if ( c >= 'a' && c <= 'f' ) \ 487 y = c - 'a' + 10; \ 488 else if ( c >= 'A' && c <= 'F' ) \ 489 y = c - 'A' + 10; \ 490 else \ 491 SL_RETURN((-1), _("sh_util_hextobinary")) 492 476 493 477 494 SL_ENTER(_("sh_util_hextobinary")); … … 479 496 while (i < bytes) 480 497 { 481 k = sh_util_hexchar(hex[i]); j = sh_util_hexchar(hex[i+1]); 498 SH_HEXCHAR(hex[i], k); 499 SH_HEXCHAR(hex[i+1], j); 500 501 binary[l] = (char)(k * 16 + j); 502 ++l; i+= 2; 503 504 /* k = sh_util_hexchar(hex[i]); j = sh_util_hexchar(hex[i+1]); 482 505 if (k != -1 && j != -1) 483 506 { … … 489 512 SL_RETURN((-1), _("sh_util_hextobinary")); 490 513 } 514 */ 491 515 } 492 516 … … 654 678 } 655 679 656 657 680 658 681 /* a simple compressor … … 785 808 UINT32 retval; 786 809 UINT32 * res; 810 static UINT32 res_vec[6]; 811 static int res_num = 0; 787 812 register int i; 813 814 if (res_num > 0) 815 { 816 retval = res_vec[res_num]; 817 res_num = (res_num == 5) ? 0 : (res_num + 1); 818 return retval; 819 } 788 820 789 821 taus_svec[0] = taus_get_long (state1); … … 798 830 (unsigned long)(6 * sizeof(UINT32))); 799 831 800 for (i = 1; i < KEY_BYT/4; ++i)832 for (i = 1; i < 6; ++i) 801 833 { 802 res [0] ^= res[i];803 res[i] = 0;804 }805 re tval = res[0];834 res_vec[i] = res[i]; 835 } 836 retval = taus_svec[0]; 837 res_num = 1; 806 838 807 839 taus_svec[0] = 0; taus_svec[1] = 0; taus_svec[2] = 0;
Note:
See TracChangeset
for help on using the changeset viewer.