Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/hunspell128/src/hunspell/affixmgr.cxx

Issue 173468: The first step towards fixing valgrind errors in the new hunspell.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/deps/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "license.hunspell" 1 #include "license.hunspell"
2 #include "license.myspell" 2 #include "license.myspell"
3 3
4 #ifndef MOZILLA_CLIENT 4 #ifndef MOZILLA_CLIENT
5 #include <cstdlib> 5 #include <cstdlib>
6 #include <cstring> 6 #include <cstring>
7 #include <cctype> 7 #include <cctype>
8 #include <cstdio> 8 #include <cstdio>
9 #else 9 #else
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 pfx = NULL; 109 pfx = NULL;
110 110
111 for (int i=0; i < SETSIZE; i++) { 111 for (int i=0; i < SETSIZE; i++) {
112 pStart[i] = NULL; 112 pStart[i] = NULL;
113 sStart[i] = NULL; 113 sStart[i] = NULL;
114 pFlag[i] = NULL; 114 pFlag[i] = NULL;
115 sFlag[i] = NULL; 115 sFlag[i] = NULL;
116 } 116 }
117 117
118 #ifdef HUNSPELL_CHROME_CLIENT 118 #ifdef HUNSPELL_CHROME_CLIENT
119 if (parse_file()) { 119 // Define dummy parameters for parse_file() to avoid changing the parameters
120 // of parse_file(). This may make it easier to merge the changes of the
121 // original hunspell.
122 FILE* affpath = NULL;
123 const char* key = NULL;
120 #else 124 #else
121
122 for (int j=0; j < CONTSIZE; j++) { 125 for (int j=0; j < CONTSIZE; j++) {
123 contclasses[j] = 0; 126 contclasses[j] = 0;
124 } 127 }
128 #endif
125 129
126 if (parse_file(affpath, key)) { 130 if (parse_file(affpath, key)) {
127 #endif
128 HUNSPELL_WARNING(stderr, "Failure loading aff file\n"); 131 HUNSPELL_WARNING(stderr, "Failure loading aff file\n");
129 } 132 }
130 133
131 if (cpdmin == -1) cpdmin = MINCPDLEN; 134 if (cpdmin == -1) cpdmin = MINCPDLEN;
132 135
133 } 136 }
134 137
135 138
136 AffixMgr::~AffixMgr() 139 AffixMgr::~AffixMgr()
137 { 140 {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if (wordchars) free(wordchars); 260 if (wordchars) free(wordchars);
258 if (wordchars_utf16) free(wordchars_utf16); 261 if (wordchars_utf16) free(wordchars_utf16);
259 if (ignorechars) free(ignorechars); 262 if (ignorechars) free(ignorechars);
260 if (ignorechars_utf16) free(ignorechars_utf16); 263 if (ignorechars_utf16) free(ignorechars_utf16);
261 if (version) free(version); 264 if (version) free(version);
262 checknum=0; 265 checknum=0;
263 } 266 }
264 267
265 268
266 // read in aff file and build up prefix and suffix entry objects 269 // read in aff file and build up prefix and suffix entry objects
267 #ifdef HUNSPELL_CHROME_CLIENT
268 int AffixMgr::parse_file()
269 #else
270 int AffixMgr::parse_file(FILE* aff_handle, const char * key) 270 int AffixMgr::parse_file(FILE* aff_handle, const char * key)
271 #endif
272 { 271 {
273 char * line = new char[MAXLNLEN+1]; // io buffers 272 char * line; // io buffers
274 char ft; // affix type 273 char ft; // affix type
275 274
276 // open the affix file 275 // open the affix file
277 #ifdef HUNSPELL_CHROME_CLIENT 276 #ifdef HUNSPELL_CHROME_CLIENT
278 // We're always UTF-8 277 // We're always UTF-8
279 utf8 = 1; 278 utf8 = 1;
280 279
281 hunspell::LineIterator af_iterator = bdict_reader->GetAffixLineIterator(); 280 // A BDICT file stores PFX and SFX lines in a special section and it provides
282 while (af_iterator.AdvanceAndCopy(line, MAXLNLEN)) { 281 // a special line iterator for reading PFX and SFX lines.
282 // We create a FileMgr object from this iterator and parse PFX and SFX lines
283 // before parsing other lines.
284 hunspell::LineIterator affix_iterator = bdict_reader->GetAffixLineIterator();
285 FileMgr* iterator = new FileMgr(&affix_iterator);
286 if (!iterator) {
287 HUNSPELL_WARNING(stderr,
288 "error: could not create a FileMgr from an affix line iterator.\n");
289 return 1;
290 }
291
292 while (line = iterator->getline()) {
283 ft = ' '; 293 ft = ' ';
284 if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P'; 294 if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P';
285 if (strncmp(line,"SFX",3) == 0) ft = complexprefixes ? 'P' : 'S'; 295 if (strncmp(line,"SFX",3) == 0) ft = complexprefixes ? 'P' : 'S';
286 if (ft != ' ') 296 if (ft != ' ')
287 parse_affix(line, ft, &af_iterator); 297 parse_affix(line, ft, iterator, NULL);
288 } 298 }
299 delete iterator;
289 300
290 hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator(); 301 // Create a FileMgr object for reading lines except PFX and SFX lines.
291 302 // We don't need to change the loop below since our FileMgr emulates the
292 // Hack to keep us from having to change all of the calls below which take 303 // original one.
293 // a LineIterator* instead of a FILE* afflst. 304 hunspell::LineIterator other_iterator = bdict_reader->GetOtherLineIterator();
294 hunspell::LineIterator* afflst = &iterator; 305 FileMgr * afflst = new FileMgr(&other_iterator);
295 306 if (!afflst) {
296 while (iterator.AdvanceAndCopy(line, MAXLNLEN)) { 307 HUNSPELL_WARNING(stderr,
308 "error: could not create a FileMgr from an other line iterator.\n");
309 return 1;
310 }
297 #else 311 #else
298 // checking flag duplication 312 // checking flag duplication
299 char dupflags[CONTSIZE]; 313 char dupflags[CONTSIZE];
300 char dupflags_ini = 1; 314 char dupflags_ini = 1;
301 315
302 // first line indicator for removing byte order mark 316 // first line indicator for removing byte order mark
303 int firstline = 1; 317 int firstline = 1;
304 318
305 // open the affix file 319 // open the affix file
306 FileMgr * afflst = new FileMgr(affpath, key); 320 FileMgr * afflst = new FileMgr(affpath, key);
307 if (!afflst) { 321 if (!afflst) {
308 HUNSPELL_WARNING(stderr, "error: could not open affix description file %s\n" ,affpath); 322 HUNSPELL_WARNING(stderr, "error: could not open affix description file %s\n" ,affpath);
309 return 1; 323 return 1;
310 } 324 }
325 #endif
311 326
312 // step one is to parse the affix file building up the internal 327 // step one is to parse the affix file building up the internal
313 // affix data structures 328 // affix data structures
314 329
315 // read in each line ignoring any that do not 330 // read in each line ignoring any that do not
316 // start with a known line type indicator 331 // start with a known line type indicator
317 while ((line = afflst->getline())) { 332 while ((line = afflst->getline())) {
318 mychomp(line); 333 mychomp(line);
319 334
335 #ifndef HUNSPELL_CHROME_CLIENT
320 /* remove byte order mark */ 336 /* remove byte order mark */
321 if (firstline) { 337 if (firstline) {
322 firstline = 0; 338 firstline = 0;
323 if (strncmp(line,"\xEF\xBB\xBF",3) == 0) { 339 if (strncmp(line,"\xEF\xBB\xBF",3) == 0) {
324 memmove(line, line+3, strlen(line+3)+1); 340 memmove(line, line+3, strlen(line+3)+1);
325 HUNSPELL_WARNING(stderr, "warning: affix file begins with byte order mark: possible incompatibility with old Hunspell versions\n"); 341 HUNSPELL_WARNING(stderr, "warning: affix file begins with byte order mark: possible incompatibility with old Hunspell versions\n");
326 } 342 }
327 } 343 }
328 #endif 344 #endif
329 /* parse in the keyboard string */ 345 /* parse in the keyboard string */
330 if (strncmp(line,"KEY",3) == 0) { 346 if (strncmp(line,"KEY",3) == 0) {
331 #ifdef HUNSPELL_CHROME_CLIENT
332 if (parse_string(line, &keystring, 0)) {
333 #else
334 if (parse_string(line, &keystring, afflst->getlinenum())) { 347 if (parse_string(line, &keystring, afflst->getlinenum())) {
335 delete afflst; 348 delete afflst;
336 #endif
337 return 1; 349 return 1;
338 } 350 }
339 } 351 }
340 352
341 /* parse in the try string */ 353 /* parse in the try string */
342 if (strncmp(line,"TRY",3) == 0) { 354 if (strncmp(line,"TRY",3) == 0) {
343 #ifdef HUNSPELL_CHROME_CLIENT
344 if (parse_string(line, &trystring, 0)) {
345 #else
346 if (parse_string(line, &trystring, afflst->getlinenum())) { 355 if (parse_string(line, &trystring, afflst->getlinenum())) {
347 delete afflst; 356 delete afflst;
348 #endif
349 return 1; 357 return 1;
350 } 358 }
351 } 359 }
352 360
353 /* parse in the name of the character set used by the .dict and .aff */ 361 /* parse in the name of the character set used by the .dict and .aff */
354 if (strncmp(line,"SET",3) == 0) { 362 if (strncmp(line,"SET",3) == 0) {
355 #ifdef HUNSPELL_CHROME_CLIENT
356 if (parse_string(line, &encoding, 0)) {
357 #else
358 if (parse_string(line, &encoding, afflst->getlinenum())) { 363 if (parse_string(line, &encoding, afflst->getlinenum())) {
359 delete afflst; 364 delete afflst;
360 #endif
361 return 1; 365 return 1;
362 } 366 }
363 if (strcmp(encoding, "UTF-8") == 0) { 367 if (strcmp(encoding, "UTF-8") == 0) {
364 utf8 = 1; 368 utf8 = 1;
365 #ifndef OPENOFFICEORG 369 #ifndef OPENOFFICEORG
366 #ifndef MOZILLA_CLIENT 370 #ifndef MOZILLA_CLIENT
367 if (initialize_utf_tbl()) return 1; 371 if (initialize_utf_tbl()) return 1;
368 #endif 372 #endif
369 #endif 373 #endif
370 } 374 }
371 } 375 }
372 376
373 /* parse COMPLEXPREFIXES for agglutinative languages with right-to-left w riting system */ 377 /* parse COMPLEXPREFIXES for agglutinative languages with right-to-left w riting system */
374 if (strncmp(line,"COMPLEXPREFIXES",15) == 0) 378 if (strncmp(line,"COMPLEXPREFIXES",15) == 0)
375 complexprefixes = 1; 379 complexprefixes = 1;
376 380
377 /* parse in the flag used by the controlled compound words */ 381 /* parse in the flag used by the controlled compound words */
378 if (strncmp(line,"COMPOUNDFLAG",12) == 0) { 382 if (strncmp(line,"COMPOUNDFLAG",12) == 0) {
379 #ifdef HUNSPELL_CHROME_CLIENT
380 if (parse_flag(line, &compoundflag)) {
381 #else
382 if (parse_flag(line, &compoundflag, afflst)) { 383 if (parse_flag(line, &compoundflag, afflst)) {
383 delete afflst; 384 delete afflst;
384 #endif
385 return 1; 385 return 1;
386 } 386 }
387 } 387 }
388 388
389 /* parse in the flag used by compound words */ 389 /* parse in the flag used by compound words */
390 if (strncmp(line,"COMPOUNDBEGIN",13) == 0) { 390 if (strncmp(line,"COMPOUNDBEGIN",13) == 0) {
391 if (complexprefixes) { 391 if (complexprefixes) {
392 #ifdef HUNSPELL_CHROME_CLIENT
393 if (parse_flag(line, &compoundend)) {
394 #else
395 if (parse_flag(line, &compoundend, afflst)) { 392 if (parse_flag(line, &compoundend, afflst)) {
396 delete afflst; 393 delete afflst;
397 #endif
398 return 1; 394 return 1;
399 } 395 }
400 } else { 396 } else {
401 #ifdef HUNSPELL_CHROME_CLIENT
402 if (parse_flag(line, &compoundbegin)) {
403 #else
404 if (parse_flag(line, &compoundbegin, afflst)) { 397 if (parse_flag(line, &compoundbegin, afflst)) {
405 delete afflst; 398 delete afflst;
406 #endif
407 return 1; 399 return 1;
408 } 400 }
409 } 401 }
410 } 402 }
411 403
412 /* parse in the flag used by compound words */ 404 /* parse in the flag used by compound words */
413 if (strncmp(line,"COMPOUNDMIDDLE",14) == 0) { 405 if (strncmp(line,"COMPOUNDMIDDLE",14) == 0) {
414 #ifdef HUNSPELL_CHROME_CLIENT
415 if (parse_flag(line, &compoundmiddle)) {
416 #else
417 if (parse_flag(line, &compoundmiddle, afflst)) { 406 if (parse_flag(line, &compoundmiddle, afflst)) {
418 delete afflst; 407 delete afflst;
419 #endif
420 return 1; 408 return 1;
421 } 409 }
422 } 410 }
423 /* parse in the flag used by compound words */ 411 /* parse in the flag used by compound words */
424 if (strncmp(line,"COMPOUNDEND",11) == 0) { 412 if (strncmp(line,"COMPOUNDEND",11) == 0) {
425 if (complexprefixes) { 413 if (complexprefixes) {
426 #ifdef HUNSPELL_CHROME_CLIENT
427 if (parse_flag(line, &compoundbegin)) {
428 #else
429 if (parse_flag(line, &compoundbegin, afflst)) { 414 if (parse_flag(line, &compoundbegin, afflst)) {
430 delete afflst; 415 delete afflst;
431 #endif
432 return 1; 416 return 1;
433 } 417 }
434 } else { 418 } else {
435 #ifdef HUNSPELL_CHROME_CLIENT
436 if (parse_flag(line, &compoundend)) {
437 #else
438 if (parse_flag(line, &compoundend, afflst)) { 419 if (parse_flag(line, &compoundend, afflst)) {
439 delete afflst; 420 delete afflst;
440 #endif
441 return 1; 421 return 1;
442 } 422 }
443 } 423 }
444 } 424 }
445 425
446 /* parse in the data used by compound_check() method */ 426 /* parse in the data used by compound_check() method */
447 if (strncmp(line,"COMPOUNDWORDMAX",15) == 0) { 427 if (strncmp(line,"COMPOUNDWORDMAX",15) == 0) {
448 #ifdef HUNSPELL_CHROME_CLIENT
449 if (parse_num(line, &cpdwordmax)) {
450 #else
451 if (parse_num(line, &cpdwordmax, afflst)) { 428 if (parse_num(line, &cpdwordmax, afflst)) {
452 delete afflst; 429 delete afflst;
453 #endif
454 return 1; 430 return 1;
455 } 431 }
456 } 432 }
457 433
458 /* parse in the flag sign compounds in dictionary */ 434 /* parse in the flag sign compounds in dictionary */
459 if (strncmp(line,"COMPOUNDROOT",12) == 0) { 435 if (strncmp(line,"COMPOUNDROOT",12) == 0) {
460 #ifdef HUNSPELL_CHROME_CLIENT
461 if (parse_flag(line, &compoundroot)) {
462 #else
463 if (parse_flag(line, &compoundroot, afflst)) { 436 if (parse_flag(line, &compoundroot, afflst)) {
464 delete afflst; 437 delete afflst;
465 #endif
466 return 1; 438 return 1;
467 } 439 }
468 } 440 }
469 441
470 /* parse in the flag used by compound_check() method */ 442 /* parse in the flag used by compound_check() method */
471 if (strncmp(line,"COMPOUNDPERMITFLAG",18) == 0) { 443 if (strncmp(line,"COMPOUNDPERMITFLAG",18) == 0) {
472 #ifdef HUNSPELL_CHROME_CLIENT
473 if (parse_flag(line, &compoundpermitflag)) {
474 #else
475 if (parse_flag(line, &compoundpermitflag, afflst)) { 444 if (parse_flag(line, &compoundpermitflag, afflst)) {
476 delete afflst; 445 delete afflst;
477 #endif
478 return 1; 446 return 1;
479 } 447 }
480 } 448 }
481 449
482 /* parse in the flag used by compound_check() method */ 450 /* parse in the flag used by compound_check() method */
483 if (strncmp(line,"COMPOUNDFORBIDFLAG",18) == 0) { 451 if (strncmp(line,"COMPOUNDFORBIDFLAG",18) == 0) {
484 #ifdef HUNSPELL_CHROME_CLIENT
485 if (parse_flag(line, &compoundforbidflag)) {
486 #else
487 if (parse_flag(line, &compoundforbidflag, afflst)) { 452 if (parse_flag(line, &compoundforbidflag, afflst)) {
488 delete afflst; 453 delete afflst;
489 #endif
490 return 1; 454 return 1;
491 } 455 }
492 } 456 }
493 457
494 if (strncmp(line,"CHECKCOMPOUNDDUP",16) == 0) { 458 if (strncmp(line,"CHECKCOMPOUNDDUP",16) == 0) {
495 checkcompounddup = 1; 459 checkcompounddup = 1;
496 } 460 }
497 461
498 if (strncmp(line,"CHECKCOMPOUNDREP",16) == 0) { 462 if (strncmp(line,"CHECKCOMPOUNDREP",16) == 0) {
499 checkcompoundrep = 1; 463 checkcompoundrep = 1;
500 } 464 }
501 465
502 if (strncmp(line,"CHECKCOMPOUNDTRIPLE",19) == 0) { 466 if (strncmp(line,"CHECKCOMPOUNDTRIPLE",19) == 0) {
503 checkcompoundtriple = 1; 467 checkcompoundtriple = 1;
504 } 468 }
505 469
506 if (strncmp(line,"SIMPLIFIEDTRIPLE",16) == 0) { 470 if (strncmp(line,"SIMPLIFIEDTRIPLE",16) == 0) {
507 simplifiedtriple = 1; 471 simplifiedtriple = 1;
508 } 472 }
509 473
510 if (strncmp(line,"CHECKCOMPOUNDCASE",17) == 0) { 474 if (strncmp(line,"CHECKCOMPOUNDCASE",17) == 0) {
511 checkcompoundcase = 1; 475 checkcompoundcase = 1;
512 } 476 }
513 477
514 if (strncmp(line,"NOSUGGEST",9) == 0) { 478 if (strncmp(line,"NOSUGGEST",9) == 0) {
515 #ifdef HUNSPELL_CHROME_CLIENT
516 if (parse_flag(line, &nosuggest)) {
517 #else
518 if (parse_flag(line, &nosuggest, afflst)) { 479 if (parse_flag(line, &nosuggest, afflst)) {
519 delete afflst; 480 delete afflst;
520 #endif
521 return 1; 481 return 1;
522 } 482 }
523 } 483 }
524 484
525 /* parse in the flag used by forbidden words */ 485 /* parse in the flag used by forbidden words */
526 if (strncmp(line,"FORBIDDENWORD",13) == 0) { 486 if (strncmp(line,"FORBIDDENWORD",13) == 0) {
527 #ifdef HUNSPELL_CHROME_CLIENT
528 if (parse_flag(line, &forbiddenword)) {
529 #else
530 if (parse_flag(line, &forbiddenword, afflst)) { 487 if (parse_flag(line, &forbiddenword, afflst)) {
531 delete afflst; 488 delete afflst;
532 #endif
533 return 1; 489 return 1;
534 } 490 }
535 } 491 }
536 492
537 /* parse in the flag used by forbidden words */ 493 /* parse in the flag used by forbidden words */
538 if (strncmp(line,"LEMMA_PRESENT",13) == 0) { 494 if (strncmp(line,"LEMMA_PRESENT",13) == 0) {
539 #ifdef HUNSPELL_CHROME_CLIENT
540 if (parse_flag(line, &lemma_present)) {
541 #else
542 if (parse_flag(line, &lemma_present, afflst)) { 495 if (parse_flag(line, &lemma_present, afflst)) {
543 delete afflst; 496 delete afflst;
544 #endif
545 return 1; 497 return 1;
546 } 498 }
547 } 499 }
548 500
549 /* parse in the flag used by circumfixes */ 501 /* parse in the flag used by circumfixes */
550 if (strncmp(line,"CIRCUMFIX",9) == 0) { 502 if (strncmp(line,"CIRCUMFIX",9) == 0) {
551 #ifdef HUNSPELL_CHROME_CLIENT
552 if (parse_flag(line, &circumfix)) {
553 #else
554 if (parse_flag(line, &circumfix, afflst)) { 503 if (parse_flag(line, &circumfix, afflst)) {
555 delete afflst; 504 delete afflst;
556 #endif
557 return 1; 505 return 1;
558 } 506 }
559 } 507 }
560 508
561 /* parse in the flag used by fogemorphemes */ 509 /* parse in the flag used by fogemorphemes */
562 if (strncmp(line,"ONLYINCOMPOUND",14) == 0) { 510 if (strncmp(line,"ONLYINCOMPOUND",14) == 0) {
563 #ifdef HUNSPELL_CHROME_CLIENT
564 if (parse_flag(line, &onlyincompound)) {
565 #else
566 if (parse_flag(line, &onlyincompound, afflst)) { 511 if (parse_flag(line, &onlyincompound, afflst)) {
567 delete afflst; 512 delete afflst;
568 #endif
569 return 1; 513 return 1;
570 } 514 }
571 } 515 }
572 516
573 /* parse in the flag used by `needaffixs' */ 517 /* parse in the flag used by `needaffixs' */
574 if (strncmp(line,"PSEUDOROOT",10) == 0) { 518 if (strncmp(line,"PSEUDOROOT",10) == 0) {
575 #ifdef HUNSPELL_CHROME_CLIENT
576 if (parse_flag(line, &needaffix)) {
577 #else
578 if (parse_flag(line, &needaffix, afflst)) { 519 if (parse_flag(line, &needaffix, afflst)) {
579 delete afflst; 520 delete afflst;
580 #endif
581 return 1; 521 return 1;
582 } 522 }
583 } 523 }
584 524
585 /* parse in the flag used by `needaffixs' */ 525 /* parse in the flag used by `needaffixs' */
586 if (strncmp(line,"NEEDAFFIX",9) == 0) { 526 if (strncmp(line,"NEEDAFFIX",9) == 0) {
587 #ifdef HUNSPELL_CHROME_CLIENT
588 if (parse_flag(line, &needaffix)) {
589 #else
590 if (parse_flag(line, &needaffix, afflst)) { 527 if (parse_flag(line, &needaffix, afflst)) {
591 delete afflst; 528 delete afflst;
592 #endif
593 return 1; 529 return 1;
594 } 530 }
595 } 531 }
596 532
597 /* parse in the minimal length for words in compounds */ 533 /* parse in the minimal length for words in compounds */
598 if (strncmp(line,"COMPOUNDMIN",11) == 0) { 534 if (strncmp(line,"COMPOUNDMIN",11) == 0) {
599 #ifdef HUNSPELL_CHROME_CLIENT
600 if (parse_num(line, &cpdmin)) {
601 #else
602 if (parse_num(line, &cpdmin, afflst)) { 535 if (parse_num(line, &cpdmin, afflst)) {
603 delete afflst; 536 delete afflst;
604 #endif
605 return 1; 537 return 1;
606 } 538 }
607 if (cpdmin < 1) cpdmin = 1; 539 if (cpdmin < 1) cpdmin = 1;
608 } 540 }
609 541
610 /* parse in the max. words and syllables in compounds */ 542 /* parse in the max. words and syllables in compounds */
611 if (strncmp(line,"COMPOUNDSYLLABLE",16) == 0) { 543 if (strncmp(line,"COMPOUNDSYLLABLE",16) == 0) {
612 #ifdef HUNSPELL_CHROME_CLIENT
613 if (parse_cpdsyllable(line)) {
614 #else
615 if (parse_cpdsyllable(line, afflst)) { 544 if (parse_cpdsyllable(line, afflst)) {
616 delete afflst; 545 delete afflst;
617 #endif
618 return 1; 546 return 1;
619 } 547 }
620 } 548 }
621 549
622 /* parse in the flag used by compound_check() method */ 550 /* parse in the flag used by compound_check() method */
623 if (strncmp(line,"SYLLABLENUM",11) == 0) { 551 if (strncmp(line,"SYLLABLENUM",11) == 0) {
624 #ifdef HUNSPELL_CHROME_CLIENT
625 if (parse_string(line, &cpdsyllablenum, 0)) {
626 #else
627 if (parse_string(line, &cpdsyllablenum, afflst->getlinenum())) { 552 if (parse_string(line, &cpdsyllablenum, afflst->getlinenum())) {
628 delete afflst; 553 delete afflst;
629 #endif
630 return 1; 554 return 1;
631 } 555 }
632 } 556 }
633 557
634 /* parse in the flag used by the controlled compound words */ 558 /* parse in the flag used by the controlled compound words */
635 if (strncmp(line,"CHECKNUM",8) == 0) { 559 if (strncmp(line,"CHECKNUM",8) == 0) {
636 checknum=1; 560 checknum=1;
637 } 561 }
638 562
639 /* parse in the extra word characters */ 563 /* parse in the extra word characters */
640 if (strncmp(line,"WORDCHARS",9) == 0) { 564 if (strncmp(line,"WORDCHARS",9) == 0) {
641 #ifdef HUNSPELL_CHROME_CLIENT
642 if (parse_array(line, &wordchars, &wordchars_utf16, &wordchars_utf16_l en, utf8, 0)) {
643 #else
644 if (parse_array(line, &wordchars, &wordchars_utf16, &wordchars_utf16_l en, utf8, afflst->getlinenum())) { 565 if (parse_array(line, &wordchars, &wordchars_utf16, &wordchars_utf16_l en, utf8, afflst->getlinenum())) {
645 delete afflst; 566 delete afflst;
646 #endif
647 return 1; 567 return 1;
648 } 568 }
649 } 569 }
650 570
651 /* parse in the ignored characters (for example, Arabic optional diacreti cs charachters */ 571 /* parse in the ignored characters (for example, Arabic optional diacreti cs charachters */
652 if (strncmp(line,"IGNORE",6) == 0) { 572 if (strncmp(line,"IGNORE",6) == 0) {
653 #ifdef HUNSPELL_CHROME_CLIENT
654 if (parse_array(line, &ignorechars, &ignorechars_utf16, &ignorechars_u tf16_len, utf8, 0)) {
655 #else
656 if (parse_array(line, &ignorechars, &ignorechars_utf16, &ignorechars_u tf16_len, utf8, afflst->getlinenum())) { 573 if (parse_array(line, &ignorechars, &ignorechars_utf16, &ignorechars_u tf16_len, utf8, afflst->getlinenum())) {
657 delete afflst; 574 delete afflst;
658 #endif
659 return 1; 575 return 1;
660 } 576 }
661 } 577 }
662 578
663 #ifndef HUNSPELL_CHROME_CLIENT 579 #ifndef HUNSPELL_CHROME_CLIENT
664 /* parse in the typical fault correcting table */ 580 /* parse in the typical fault correcting table */
665 if (strncmp(line,"REP",3) == 0) { 581 if (strncmp(line,"REP",3) == 0) {
666 if (parse_reptable(line, afflst)) { 582 if (parse_reptable(line, afflst)) {
667 delete afflst; 583 delete afflst;
668 return 1; 584 return 1;
669 } 585 }
670 } 586 }
671 #endif 587 #endif
672 588
673 /* parse in the input conversion table */ 589 /* parse in the input conversion table */
674 if (strncmp(line,"ICONV",5) == 0) { 590 if (strncmp(line,"ICONV",5) == 0) {
675 if (parse_convtable(line, afflst, &iconvtable, "ICONV")) { 591 if (parse_convtable(line, afflst, &iconvtable, "ICONV")) {
676 #ifndef HUNSPELL_CHROME_CLIENT
677 delete afflst; 592 delete afflst;
678 #endif
679 return 1; 593 return 1;
680 } 594 }
681 } 595 }
682 596
683 /* parse in the input conversion table */ 597 /* parse in the input conversion table */
684 if (strncmp(line,"OCONV",5) == 0) { 598 if (strncmp(line,"OCONV",5) == 0) {
685 if (parse_convtable(line, afflst, &oconvtable, "OCONV")) { 599 if (parse_convtable(line, afflst, &oconvtable, "OCONV")) {
686 #ifndef HUNSPELL_CHROME_CLIENT
687 delete afflst; 600 delete afflst;
688 #endif
689 return 1; 601 return 1;
690 } 602 }
691 } 603 }
692 604
693 /* parse in the phonetic translation table */ 605 /* parse in the phonetic translation table */
694 if (strncmp(line,"PHONE",5) == 0) { 606 if (strncmp(line,"PHONE",5) == 0) {
695 if (parse_phonetable(line, afflst)) { 607 if (parse_phonetable(line, afflst)) {
696 #ifndef HUNSPELL_CHROME_CLIENT
697 delete afflst; 608 delete afflst;
698 #endif
699 return 1; 609 return 1;
700 } 610 }
701 } 611 }
702 612
703 /* parse in the checkcompoundpattern table */ 613 /* parse in the checkcompoundpattern table */
704 if (strncmp(line,"CHECKCOMPOUNDPATTERN",20) == 0) { 614 if (strncmp(line,"CHECKCOMPOUNDPATTERN",20) == 0) {
705 if (parse_checkcpdtable(line, afflst)) { 615 if (parse_checkcpdtable(line, afflst)) {
706 #ifndef HUNSPELL_CHROME_CLIENT
707 delete afflst; 616 delete afflst;
708 #endif
709 return 1; 617 return 1;
710 } 618 }
711 } 619 }
712 620
713 /* parse in the defcompound table */ 621 /* parse in the defcompound table */
714 if (strncmp(line,"COMPOUNDRULE",12) == 0) { 622 if (strncmp(line,"COMPOUNDRULE",12) == 0) {
715 if (parse_defcpdtable(line, afflst)) { 623 if (parse_defcpdtable(line, afflst)) {
716 #ifndef HUNSPELL_CHROME_CLIENT
717 delete afflst; 624 delete afflst;
718 #endif
719 return 1; 625 return 1;
720 } 626 }
721 } 627 }
722 628
723 /* parse in the related character map table */ 629 /* parse in the related character map table */
724 if (strncmp(line,"MAP",3) == 0) { 630 if (strncmp(line,"MAP",3) == 0) {
725 if (parse_maptable(line, afflst)) { 631 if (parse_maptable(line, afflst)) {
726 #ifndef HUNSPELL_CHROME_CLIENT
727 delete afflst; 632 delete afflst;
728 #endif
729 return 1; 633 return 1;
730 } 634 }
731 } 635 }
732 636
733 /* parse in the word breakpoints table */ 637 /* parse in the word breakpoints table */
734 if (strncmp(line,"BREAK",5) == 0) { 638 if (strncmp(line,"BREAK",5) == 0) {
735 if (parse_breaktable(line, afflst)) { 639 if (parse_breaktable(line, afflst)) {
736 #ifndef HUNSPELL_CHROME_CLIENT
737 delete afflst; 640 delete afflst;
738 #endif
739 return 1; 641 return 1;
740 } 642 }
741 } 643 }
742 644
743 /* parse in the language for language specific codes */ 645 /* parse in the language for language specific codes */
744 if (strncmp(line,"LANG",4) == 0) { 646 if (strncmp(line,"LANG",4) == 0) {
745 #ifdef HUNSPELL_CHROME_CLIENT
746 if (parse_string(line, &lang, 0)) {
747 #else
748 if (parse_string(line, &lang, afflst->getlinenum())) { 647 if (parse_string(line, &lang, afflst->getlinenum())) {
749 delete afflst; 648 delete afflst;
750 #endif
751 return 1; 649 return 1;
752 } 650 }
753 langnum = get_lang_num(lang); 651 langnum = get_lang_num(lang);
754 } 652 }
755 653
756 if (strncmp(line,"VERSION",7) == 0) { 654 if (strncmp(line,"VERSION",7) == 0) {
757 for(line = line + 7; *line == ' ' || *line == '\t'; line++); 655 for(line = line + 7; *line == ' ' || *line == '\t'; line++);
758 version = mystrdup(line); 656 version = mystrdup(line);
759 } 657 }
760 658
761 if (strncmp(line,"MAXNGRAMSUGS",12) == 0) { 659 if (strncmp(line,"MAXNGRAMSUGS",12) == 0) {
762 #ifdef HUNSPELL_CHROME_CLIENT
763 if (parse_num(line, &maxngramsugs)) {
764 #else
765 if (parse_num(line, &maxngramsugs, afflst)) { 660 if (parse_num(line, &maxngramsugs, afflst)) {
766 delete afflst; 661 delete afflst;
767 #endif
768 return 1; 662 return 1;
769 } 663 }
770 } 664 }
771 665
772 if (strncmp(line,"NOSPLITSUGS",11) == 0) { 666 if (strncmp(line,"NOSPLITSUGS",11) == 0) {
773 nosplitsugs=1; 667 nosplitsugs=1;
774 } 668 }
775 669
776 if (strncmp(line,"FULLSTRIP",9) == 0) { 670 if (strncmp(line,"FULLSTRIP",9) == 0) {
777 fullstrip=1; 671 fullstrip=1;
778 } 672 }
779 673
780 if (strncmp(line,"SUGSWITHDOTS",12) == 0) { 674 if (strncmp(line,"SUGSWITHDOTS",12) == 0) {
781 sugswithdots=1; 675 sugswithdots=1;
782 } 676 }
783 677
784 /* parse in the flag used by forbidden words */ 678 /* parse in the flag used by forbidden words */
785 if (strncmp(line,"KEEPCASE",8) == 0) { 679 if (strncmp(line,"KEEPCASE",8) == 0) {
786 #ifdef HUNSPELL_CHROME_CLIENT
787 if (parse_flag(line, &keepcase)) {
788 #else
789 if (parse_flag(line, &keepcase, afflst)) { 680 if (parse_flag(line, &keepcase, afflst)) {
790 delete afflst; 681 delete afflst;
791 #endif
792 return 1; 682 return 1;
793 } 683 }
794 } 684 }
795 685
796 /* parse in the flag used by the affix generator */ 686 /* parse in the flag used by the affix generator */
797 if (strncmp(line,"SUBSTANDARD",11) == 0) { 687 if (strncmp(line,"SUBSTANDARD",11) == 0) {
798 #ifdef HUNSPELL_CHROME_CLIENT
799 if (parse_flag(line, &substandard)) {
800 #else
801 if (parse_flag(line, &substandard, afflst)) { 688 if (parse_flag(line, &substandard, afflst)) {
802 delete afflst; 689 delete afflst;
803 #endif
804 return 1; 690 return 1;
805 } 691 }
806 } 692 }
807 693
808 if (strncmp(line,"CHECKSHARPS",11) == 0) { 694 if (strncmp(line,"CHECKSHARPS",11) == 0) {
809 checksharps=1; 695 checksharps=1;
810 } 696 }
811 697
812 #ifndef HUNSPELL_CHROME_CLIENT // Chrome handled affixes above. 698 #ifndef HUNSPELL_CHROME_CLIENT // Chrome handled affixes above.
813 /* parse this affix: P - prefix, S - suffix */ 699 /* parse this affix: P - prefix, S - suffix */
814 ft = ' '; 700 ft = ' ';
815 if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P'; 701 if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P';
816 if (strncmp(line,"SFX",3) == 0) ft = complexprefixes ? 'P' : 'S'; 702 if (strncmp(line,"SFX",3) == 0) ft = complexprefixes ? 'P' : 'S';
817 if (ft != ' ') { 703 if (ft != ' ') {
818 if (dupflags_ini) { 704 if (dupflags_ini) {
819 memset(dupflags, 0, sizeof(dupflags)); 705 memset(dupflags, 0, sizeof(dupflags));
820 dupflags_ini = 0; 706 dupflags_ini = 0;
821 } 707 }
822 if (parse_affix(line, ft, afflst, dupflags)) { 708 if (parse_affix(line, ft, afflst, dupflags)) {
823 delete afflst; 709 delete afflst;
824 process_pfx_tree_to_list(); 710 process_pfx_tree_to_list();
825 process_sfx_tree_to_list(); 711 process_sfx_tree_to_list();
826 return 1; 712 return 1;
827 } 713 }
828 } 714 }
829 #endif 715 #endif
830 } 716 }
831 717
832 #ifndef HUNSPELL_CHROME_CLIENT
833 delete afflst; 718 delete afflst;
834 #endif
835 719
836 // convert affix trees to sorted list 720 // convert affix trees to sorted list
837 process_pfx_tree_to_list(); 721 process_pfx_tree_to_list();
838 process_sfx_tree_to_list(); 722 process_sfx_tree_to_list();
839 723
840 // now we can speed up performance greatly taking advantage of the 724 // now we can speed up performance greatly taking advantage of the
841 // relationship between the affixes and the idea of "subsets". 725 // relationship between the affixes and the idea of "subsets".
842 726
843 // View each prefix as a potential leading subset of another and view 727 // View each prefix as a potential leading subset of another and view
844 // each suffix (reversed) as a potential trailing subset of another. 728 // each suffix (reversed) as a potential trailing subset of another.
(...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 return nosplitsugs; 3338 return nosplitsugs;
3455 } 3339 }
3456 3340
3457 // return sugswithdots 3341 // return sugswithdots
3458 int AffixMgr::get_sugswithdots(void) 3342 int AffixMgr::get_sugswithdots(void)
3459 { 3343 {
3460 return sugswithdots; 3344 return sugswithdots;
3461 } 3345 }
3462 3346
3463 /* parse flag */ 3347 /* parse flag */
3464 #ifdef HUNSPELL_CHROME_CLIENT
3465 int AffixMgr::parse_flag(char * line, unsigned short * out)
3466 #else
3467 int AffixMgr::parse_flag(char * line, unsigned short * out, FileMgr * af) 3348 int AffixMgr::parse_flag(char * line, unsigned short * out, FileMgr * af)
3468 #endif
3469 { 3349 {
3470 char * s = NULL; 3350 char * s = NULL;
3471 if (*out != FLAG_NULL && !(*out >= DEFAULTFLAGS)) { 3351 if (*out != FLAG_NULL && !(*out >= DEFAULTFLAGS)) {
3472 HUNSPELL_WARNING(stderr, "error:multiple definitions of an affix file para meter\n"); 3352 HUNSPELL_WARNING(stderr, "error:multiple definitions of an affix file para meter\n");
3473 return 1; 3353 return 1;
3474 } 3354 }
3475 if (parse_string(line, &s, 0)) return 1; 3355 if (parse_string(line, &s, 0)) return 1;
3476 *out = pHMgr->decode_flag(s); 3356 *out = pHMgr->decode_flag(s);
3477 free(s); 3357 free(s);
3478 return 0; 3358 return 0;
3479 } 3359 }
3480 3360
3481 /* parse num */ 3361 /* parse num */
3482 #ifdef HUNSPELL_CHROME_CLIENT
3483 int AffixMgr::parse_num(char * line, int * out)
3484 #else
3485 int AffixMgr::parse_num(char * line, int * out, FileMgr * af) 3362 int AffixMgr::parse_num(char * line, int * out, FileMgr * af)
3486 #endif
3487 { 3363 {
3488 char * s = NULL; 3364 char * s = NULL;
3489 if (*out != -1) { 3365 if (*out != -1) {
3490 HUNSPELL_WARNING(stderr, "error: multiple definitions of an affix file par ameter\n"); 3366 HUNSPELL_WARNING(stderr, "error: multiple definitions of an affix file par ameter\n");
3491 return 1; 3367 return 1;
3492 } 3368 }
3493 if (parse_string(line, &s, 0)) return 1; 3369 if (parse_string(line, &s, 0)) return 1;
3494 *out = atoi(s); 3370 *out = atoi(s);
3495 free(s); 3371 free(s);
3496 return 0; 3372 return 0;
3497 } 3373 }
3498 3374
3499 /* parse in the max syllablecount of compound words and */ 3375 /* parse in the max syllablecount of compound words and */
3500 #ifdef HUNSPELL_CHROME_CLIENT
3501 int AffixMgr::parse_cpdsyllable(char * line)
3502 #else
3503 int AffixMgr::parse_cpdsyllable(char * line, FileMgr * af) 3376 int AffixMgr::parse_cpdsyllable(char * line, FileMgr * af)
3504 #endif
3505 { 3377 {
3506 char * tp = line; 3378 char * tp = line;
3507 char * piece; 3379 char * piece;
3508 int i = 0; 3380 int i = 0;
3509 int np = 0; 3381 int np = 0;
3510 w_char w[MAXWORDLEN]; 3382 w_char w[MAXWORDLEN];
3511 piece = mystrsep(&tp, 0); 3383 piece = mystrsep(&tp, 0);
3512 while (piece) { 3384 while (piece) {
3513 if (*piece != '\0') { 3385 if (*piece != '\0') {
3514 switch(i) { 3386 switch(i) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af-> getlinenum()); 3488 HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af-> getlinenum());
3617 numrep = 0; 3489 numrep = 0;
3618 return 1; 3490 return 1;
3619 } 3491 }
3620 } 3492 }
3621 return 0; 3493 return 0;
3622 } 3494 }
3623 #endif 3495 #endif
3624 3496
3625 /* parse in the typical fault correcting table */ 3497 /* parse in the typical fault correcting table */
3626 #ifdef HUNSPELL_CHROME_CLIENT
3627 int AffixMgr::parse_convtable(char * line, hunspell::LineIterator* iterator, Re pList ** rl, const char * keyword)
3628 #else
3629 int AffixMgr::parse_convtable(char * line, FileMgr * af, RepList ** rl, const c har * keyword) 3498 int AffixMgr::parse_convtable(char * line, FileMgr * af, RepList ** rl, const c har * keyword)
3630 #endif
3631 { 3499 {
3632 if (*rl) { 3500 if (*rl) {
3633 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3501 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
3634 return 1; 3502 return 1;
3635 } 3503 }
3636 char * tp = line; 3504 char * tp = line;
3637 char * piece; 3505 char * piece;
3638 int i = 0; 3506 int i = 0;
3639 int np = 0; 3507 int np = 0;
3640 int numrl = 0; 3508 int numrl = 0;
(...skipping 20 matching lines...) Expand all
3661 piece = mystrsep(&tp, 0); 3529 piece = mystrsep(&tp, 0);
3662 } 3530 }
3663 if (np != 2) { 3531 if (np != 2) {
3664 HUNSPELL_WARNING(stderr, "error: missing data\n"); 3532 HUNSPELL_WARNING(stderr, "error: missing data\n");
3665 return 1; 3533 return 1;
3666 } 3534 }
3667 3535
3668 /* now parse the num lines to read in the remainder of the table */ 3536 /* now parse the num lines to read in the remainder of the table */
3669 char * nl = line; 3537 char * nl = line;
3670 for (int j=0; j < numrl; j++) { 3538 for (int j=0; j < numrl; j++) {
3671 #ifdef HUNSPELL_CHROME_CLIENT
3672 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
3673 return 1;
3674 #else
3675 if (!(nl = af->getline())) return 1; 3539 if (!(nl = af->getline())) return 1;
3676 #endif
3677 mychomp(nl); 3540 mychomp(nl);
3678 tp = nl; 3541 tp = nl;
3679 i = 0; 3542 i = 0;
3680 char * pattern = NULL; 3543 char * pattern = NULL;
3681 char * pattern2 = NULL; 3544 char * pattern2 = NULL;
3682 piece = mystrsep(&tp, 0); 3545 piece = mystrsep(&tp, 0);
3683 while (piece) { 3546 while (piece) {
3684 if (*piece != '\0') { 3547 if (*piece != '\0') {
3685 switch(i) { 3548 switch(i) {
3686 case 0: { 3549 case 0: {
(...skipping 20 matching lines...) Expand all
3707 HUNSPELL_WARNING(stderr, "error: table is corrupt\n"); 3570 HUNSPELL_WARNING(stderr, "error: table is corrupt\n");
3708 return 1; 3571 return 1;
3709 } 3572 }
3710 (*rl)->add(pattern, pattern2); 3573 (*rl)->add(pattern, pattern2);
3711 } 3574 }
3712 return 0; 3575 return 0;
3713 } 3576 }
3714 3577
3715 3578
3716 /* parse in the typical fault correcting table */ 3579 /* parse in the typical fault correcting table */
3717 #ifdef HUNSPELL_CHROME_CLIENT
3718 int AffixMgr::parse_phonetable(char * line, hunspell::LineIterator* iterator)
3719 #else
3720 int AffixMgr::parse_phonetable(char * line, FileMgr * af) 3580 int AffixMgr::parse_phonetable(char * line, FileMgr * af)
3721 #endif
3722 { 3581 {
3723 if (phone) { 3582 if (phone) {
3724 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3583 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
3725 return 1; 3584 return 1;
3726 } 3585 }
3727 char * tp = line; 3586 char * tp = line;
3728 char * piece; 3587 char * piece;
3729 int i = 0; 3588 int i = 0;
3730 int np = 0; 3589 int np = 0;
3731 piece = mystrsep(&tp, 0); 3590 piece = mystrsep(&tp, 0);
(...skipping 23 matching lines...) Expand all
3755 piece = mystrsep(&tp, 0); 3614 piece = mystrsep(&tp, 0);
3756 } 3615 }
3757 if (np != 2) { 3616 if (np != 2) {
3758 HUNSPELL_WARNING(stderr, "error: missing data\n"); 3617 HUNSPELL_WARNING(stderr, "error: missing data\n");
3759 return 1; 3618 return 1;
3760 } 3619 }
3761 3620
3762 /* now parse the phone->num lines to read in the remainder of the table */ 3621 /* now parse the phone->num lines to read in the remainder of the table */
3763 char * nl = line; 3622 char * nl = line;
3764 for (int j=0; j < phone->num; j++) { 3623 for (int j=0; j < phone->num; j++) {
3765 #ifdef HUNSPELL_CHROME_CLIENT
3766 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
3767 return 1;
3768 #else
3769 if (!(nl = af->getline())) return 1; 3624 if (!(nl = af->getline())) return 1;
3770 #endif
3771 mychomp(nl); 3625 mychomp(nl);
3772 tp = nl; 3626 tp = nl;
3773 i = 0; 3627 i = 0;
3774 phone->rules[j * 2] = NULL; 3628 phone->rules[j * 2] = NULL;
3775 phone->rules[j * 2 + 1] = NULL; 3629 phone->rules[j * 2 + 1] = NULL;
3776 piece = mystrsep(&tp, 0); 3630 piece = mystrsep(&tp, 0);
3777 while (piece) { 3631 while (piece) {
3778 if (*piece != '\0') { 3632 if (*piece != '\0') {
3779 switch(i) { 3633 switch(i) {
3780 case 0: { 3634 case 0: {
(...skipping 18 matching lines...) Expand all
3799 return 1; 3653 return 1;
3800 } 3654 }
3801 } 3655 }
3802 phone->rules[phone->num * 2] = mystrdup(""); 3656 phone->rules[phone->num * 2] = mystrdup("");
3803 phone->rules[phone->num * 2 + 1] = mystrdup(""); 3657 phone->rules[phone->num * 2 + 1] = mystrdup("");
3804 init_phonet_hash(*phone); 3658 init_phonet_hash(*phone);
3805 return 0; 3659 return 0;
3806 } 3660 }
3807 3661
3808 /* parse in the checkcompoundpattern table */ 3662 /* parse in the checkcompoundpattern table */
3809 #if HUNSPELL_CHROME_CLIENT
3810 int AffixMgr::parse_checkcpdtable(char * line, hunspell::LineIterator* iterator )
3811 #else
3812 int AffixMgr::parse_checkcpdtable(char * line, FileMgr * af) 3663 int AffixMgr::parse_checkcpdtable(char * line, FileMgr * af)
3813 #endif
3814 { 3664 {
3815 if (numcheckcpd != 0) { 3665 if (numcheckcpd != 0) {
3816 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3666 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
3817 return 1; 3667 return 1;
3818 } 3668 }
3819 char * tp = line; 3669 char * tp = line;
3820 char * piece; 3670 char * piece;
3821 int i = 0; 3671 int i = 0;
3822 int np = 0; 3672 int np = 0;
3823 piece = mystrsep(&tp, 0); 3673 piece = mystrsep(&tp, 0);
(...skipping 19 matching lines...) Expand all
3843 piece = mystrsep(&tp, 0); 3693 piece = mystrsep(&tp, 0);
3844 } 3694 }
3845 if (np != 2) { 3695 if (np != 2) {
3846 HUNSPELL_WARNING(stderr, "error: missing data\n"); 3696 HUNSPELL_WARNING(stderr, "error: missing data\n");
3847 return 1; 3697 return 1;
3848 } 3698 }
3849 3699
3850 /* now parse the numcheckcpd lines to read in the remainder of the table */ 3700 /* now parse the numcheckcpd lines to read in the remainder of the table */
3851 char * nl = line; 3701 char * nl = line;
3852 for (int j=0; j < numcheckcpd; j++) { 3702 for (int j=0; j < numcheckcpd; j++) {
3853 #ifdef HUNSPELL_CHROME_CLIENT
3854 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
3855 return 1;
3856 #else
3857 if (!(nl = af->getline())) return 1; 3703 if (!(nl = af->getline())) return 1;
3858 #endif
3859 mychomp(nl); 3704 mychomp(nl);
3860 tp = nl; 3705 tp = nl;
3861 i = 0; 3706 i = 0;
3862 checkcpdtable[j].pattern = NULL; 3707 checkcpdtable[j].pattern = NULL;
3863 checkcpdtable[j].pattern2 = NULL; 3708 checkcpdtable[j].pattern2 = NULL;
3864 checkcpdtable[j].pattern3 = NULL; 3709 checkcpdtable[j].pattern3 = NULL;
3865 checkcpdtable[j].cond = FLAG_NULL; 3710 checkcpdtable[j].cond = FLAG_NULL;
3866 checkcpdtable[j].cond2 = FLAG_NULL; 3711 checkcpdtable[j].cond2 = FLAG_NULL;
3867 piece = mystrsep(&tp, 0); 3712 piece = mystrsep(&tp, 0);
3868 while (piece) { 3713 while (piece) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 if ((!(checkcpdtable[j].pattern)) || (!(checkcpdtable[j].pattern2))) { 3748 if ((!(checkcpdtable[j].pattern)) || (!(checkcpdtable[j].pattern2))) {
3904 HUNSPELL_WARNING(stderr, "error: table is corrupt\n"); 3749 HUNSPELL_WARNING(stderr, "error: table is corrupt\n");
3905 numcheckcpd = 0; 3750 numcheckcpd = 0;
3906 return 1; 3751 return 1;
3907 } 3752 }
3908 } 3753 }
3909 return 0; 3754 return 0;
3910 } 3755 }
3911 3756
3912 /* parse in the compound rule table */ 3757 /* parse in the compound rule table */
3913 #ifdef HUNSPELL_CHROME_CLIENT
3914 int AffixMgr::parse_defcpdtable(char * line, hunspell::LineIterator* iterator)
3915 #else
3916 int AffixMgr::parse_defcpdtable(char * line, FileMgr * af) 3758 int AffixMgr::parse_defcpdtable(char * line, FileMgr * af)
3917 #endif
3918 { 3759 {
3919 if (numdefcpd != 0) { 3760 if (numdefcpd != 0) {
3920 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3761 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
3921 return 1; 3762 return 1;
3922 } 3763 }
3923 char * tp = line; 3764 char * tp = line;
3924 char * piece; 3765 char * piece;
3925 int i = 0; 3766 int i = 0;
3926 int np = 0; 3767 int np = 0;
3927 piece = mystrsep(&tp, 0); 3768 piece = mystrsep(&tp, 0);
(...skipping 19 matching lines...) Expand all
3947 piece = mystrsep(&tp, 0); 3788 piece = mystrsep(&tp, 0);
3948 } 3789 }
3949 if (np != 2) { 3790 if (np != 2) {
3950 HUNSPELL_WARNING(stderr, "error: missing data\n"); 3791 HUNSPELL_WARNING(stderr, "error: missing data\n");
3951 return 1; 3792 return 1;
3952 } 3793 }
3953 3794
3954 /* now parse the numdefcpd lines to read in the remainder of the table */ 3795 /* now parse the numdefcpd lines to read in the remainder of the table */
3955 char * nl = line; 3796 char * nl = line;
3956 for (int j=0; j < numdefcpd; j++) { 3797 for (int j=0; j < numdefcpd; j++) {
3957 #ifdef HUNSPELL_CHROME_CLIENT
3958 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
3959 return 1;
3960 #else
3961 if (!(nl = af->getline())) return 1; 3798 if (!(nl = af->getline())) return 1;
3962 #endif
3963 mychomp(nl); 3799 mychomp(nl);
3964 tp = nl; 3800 tp = nl;
3965 i = 0; 3801 i = 0;
3966 defcpdtable[j].def = NULL; 3802 defcpdtable[j].def = NULL;
3967 piece = mystrsep(&tp, 0); 3803 piece = mystrsep(&tp, 0);
3968 while (piece) { 3804 while (piece) {
3969 if (*piece != '\0') { 3805 if (*piece != '\0') {
3970 switch(i) { 3806 switch(i) {
3971 case 0: { 3807 case 0: {
3972 if (strncmp(piece, "COMPOUNDRULE", 12) != 0) { 3808 if (strncmp(piece, "COMPOUNDRULE", 12) != 0) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4011 HUNSPELL_WARNING(stderr, "error: line table is corrupt\n"); 3847 HUNSPELL_WARNING(stderr, "error: line table is corrupt\n");
4012 numdefcpd = 0; 3848 numdefcpd = 0;
4013 return 1; 3849 return 1;
4014 } 3850 }
4015 } 3851 }
4016 return 0; 3852 return 0;
4017 } 3853 }
4018 3854
4019 3855
4020 /* parse in the character map table */ 3856 /* parse in the character map table */
4021 #ifdef HUNSPELL_CHROME_CLIENT
4022 int AffixMgr::parse_maptable(char * line, hunspell::LineIterator* iterator)
4023 #else
4024 int AffixMgr::parse_maptable(char * line, FileMgr * af) 3857 int AffixMgr::parse_maptable(char * line, FileMgr * af)
4025 #endif
4026 { 3858 {
4027 if (nummap != 0) { 3859 if (nummap != 0) {
4028 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3860 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
4029 return 1; 3861 return 1;
4030 } 3862 }
4031 char * tp = line; 3863 char * tp = line;
4032 char * piece; 3864 char * piece;
4033 int i = 0; 3865 int i = 0;
4034 int np = 0; 3866 int np = 0;
4035 piece = mystrsep(&tp, 0); 3867 piece = mystrsep(&tp, 0);
(...skipping 19 matching lines...) Expand all
4055 piece = mystrsep(&tp, 0); 3887 piece = mystrsep(&tp, 0);
4056 } 3888 }
4057 if (np != 2) { 3889 if (np != 2) {
4058 HUNSPELL_WARNING(stderr, "error: line missing data\n"); 3890 HUNSPELL_WARNING(stderr, "error: line missing data\n");
4059 return 1; 3891 return 1;
4060 } 3892 }
4061 3893
4062 /* now parse the nummap lines to read in the remainder of the table */ 3894 /* now parse the nummap lines to read in the remainder of the table */
4063 char * nl = line; 3895 char * nl = line;
4064 for (int j=0; j < nummap; j++) { 3896 for (int j=0; j < nummap; j++) {
4065 #ifdef HUNSPELL_CHROME_CLIENT
4066 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
4067 return 1;
4068 #else
4069 if (!(nl = af->getline())) return 1; 3897 if (!(nl = af->getline())) return 1;
4070 #endif
4071 mychomp(nl); 3898 mychomp(nl);
4072 tp = nl; 3899 tp = nl;
4073 i = 0; 3900 i = 0;
4074 maptable[j].set = NULL; 3901 maptable[j].set = NULL;
4075 maptable[j].len = 0; 3902 maptable[j].len = 0;
4076 piece = mystrsep(&tp, 0); 3903 piece = mystrsep(&tp, 0);
4077 while (piece) { 3904 while (piece) {
4078 if (*piece != '\0') { 3905 if (*piece != '\0') {
4079 switch(i) { 3906 switch(i) {
4080 case 0: { 3907 case 0: {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4113 if ((!(maptable[j].set || maptable[j].set_utf16)) || (!(maptable[j].len) )) { 3940 if ((!(maptable[j].set || maptable[j].set_utf16)) || (!(maptable[j].len) )) {
4114 HUNSPELL_WARNING(stderr, "error: table is corrupt\n"); 3941 HUNSPELL_WARNING(stderr, "error: table is corrupt\n");
4115 nummap = 0; 3942 nummap = 0;
4116 return 1; 3943 return 1;
4117 } 3944 }
4118 } 3945 }
4119 return 0; 3946 return 0;
4120 } 3947 }
4121 3948
4122 /* parse in the word breakpoint table */ 3949 /* parse in the word breakpoint table */
4123 #ifdef HUNSPELL_CHROME_CLIENT
4124 int AffixMgr::parse_breaktable(char * line, hunspell::LineIterator* iterator)
4125 #else
4126 int AffixMgr::parse_breaktable(char * line, FileMgr * af) 3950 int AffixMgr::parse_breaktable(char * line, FileMgr * af)
4127 #endif
4128 { 3951 {
4129 if (numbreak != 0) { 3952 if (numbreak != 0) {
4130 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n"); 3953 HUNSPELL_WARNING(stderr, "error: multiple table definitions\n");
4131 return 1; 3954 return 1;
4132 } 3955 }
4133 char * tp = line; 3956 char * tp = line;
4134 char * piece; 3957 char * piece;
4135 int i = 0; 3958 int i = 0;
4136 int np = 0; 3959 int np = 0;
4137 piece = mystrsep(&tp, 0); 3960 piece = mystrsep(&tp, 0);
(...skipping 19 matching lines...) Expand all
4157 piece = mystrsep(&tp, 0); 3980 piece = mystrsep(&tp, 0);
4158 } 3981 }
4159 if (np != 2) { 3982 if (np != 2) {
4160 HUNSPELL_WARNING(stderr, "error: missing data\n"); 3983 HUNSPELL_WARNING(stderr, "error: missing data\n");
4161 return 1; 3984 return 1;
4162 } 3985 }
4163 3986
4164 /* now parse the numbreak lines to read in the remainder of the table */ 3987 /* now parse the numbreak lines to read in the remainder of the table */
4165 char * nl = line; 3988 char * nl = line;
4166 for (int j=0; j < numbreak; j++) { 3989 for (int j=0; j < numbreak; j++) {
4167 #ifdef HUNSPELL_CHROME_CLIENT
4168 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
4169 return 1;
4170 #else
4171 if (!(nl = af->getline())) return 1; 3990 if (!(nl = af->getline())) return 1;
4172 #endif
4173 mychomp(nl); 3991 mychomp(nl);
4174 tp = nl; 3992 tp = nl;
4175 i = 0; 3993 i = 0;
4176 piece = mystrsep(&tp, 0); 3994 piece = mystrsep(&tp, 0);
4177 while (piece) { 3995 while (piece) {
4178 if (*piece != '\0') { 3996 if (*piece != '\0') {
4179 switch(i) { 3997 switch(i) {
4180 case 0: { 3998 case 0: {
4181 if (strncmp(piece,"BREAK",5) != 0) { 3999 if (strncmp(piece,"BREAK",5) != 0) {
4182 HUNSPELL_WARNING(stderr, "error: table is corru pt\n"); 4000 HUNSPELL_WARNING(stderr, "error: table is corru pt\n");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4221 case '^': { 4039 case '^': {
4222 if (*(k+1) == ']') neg = 1; else *(k+1) = *k; 4040 if (*(k+1) == ']') neg = 1; else *(k+1) = *k;
4223 break; 4041 break;
4224 } 4042 }
4225 default: { 4043 default: {
4226 if (neg) *(k+1) = *k; 4044 if (neg) *(k+1) = *k;
4227 } 4045 }
4228 } 4046 }
4229 } 4047 }
4230 } 4048 }
4231 #ifdef HUNSPELL_CHROME_CLIENT
4232 int AffixMgr::parse_affix(char * line, const char at, hunspell::LineIterator* i terator)
4233 #else
4234 int AffixMgr::parse_affix(char * line, const char at, FileMgr * af, char * dupf lags) 4049 int AffixMgr::parse_affix(char * line, const char at, FileMgr * af, char * dupf lags)
4235 #endif
4236 { 4050 {
4237 int numents = 0; // number of affentry structures to parse 4051 int numents = 0; // number of affentry structures to parse
4238 4052
4239 unsigned short aflag = 0; // affix char identifier 4053 unsigned short aflag = 0; // affix char identifier
4240 4054
4241 char ff=0; 4055 char ff=0;
4242 struct affentry * ptr= NULL; 4056 struct affentry * ptr= NULL;
4243 struct affentry * nptr= NULL; 4057 struct affentry * nptr= NULL;
4244 4058
4245 char * tp = line; 4059 char * tp = line;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 } 4131 }
4318 free(ptr); 4132 free(ptr);
4319 return 1; 4133 return 1;
4320 } 4134 }
4321 4135
4322 // store away ptr to first affentry 4136 // store away ptr to first affentry
4323 nptr = ptr; 4137 nptr = ptr;
4324 4138
4325 // now parse numents affentries for this affix 4139 // now parse numents affentries for this affix
4326 for (int j=0; j < numents; j++) { 4140 for (int j=0; j < numents; j++) {
4327 #ifdef HUNSPELL_CHROME_CLIENT
4328 if (!iterator->AdvanceAndCopy(nl, MAXLNLEN))
4329 return 1;
4330 #else
4331 if (!(nl = af->getline())) return 1; 4141 if (!(nl = af->getline())) return 1;
4332 #endif
4333 mychomp(nl); 4142 mychomp(nl);
4334 tp = nl; 4143 tp = nl;
4335 i = 0; 4144 i = 0;
4336 np = 0; 4145 np = 0;
4337 4146
4338 // split line into pieces 4147 // split line into pieces
4339 piece = mystrsep(&tp, 0); 4148 piece = mystrsep(&tp, 0);
4340 while (piece) { 4149 while (piece) {
4341 if (*piece != '\0') { 4150 if (*piece != '\0') {
4342 switch(i) { 4151 switch(i) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
4586 HUNSPELL_WARNING(stderr, "warning: line %d: incompatible stripping c haracters and condition\n", linenum); 4395 HUNSPELL_WARNING(stderr, "warning: line %d: incompatible stripping c haracters and condition\n", linenum);
4587 return 0; 4396 return 0;
4588 } 4397 }
4589 } 4398 }
4590 } 4399 }
4591 if (j < 0) return 1; 4400 if (j < 0) return 1;
4592 } 4401 }
4593 } 4402 }
4594 return 0; 4403 return 0;
4595 } 4404 }
OLDNEW
« no previous file with comments | « third_party/hunspell128/src/hunspell/affixmgr.hxx ('k') | third_party/hunspell128/src/hunspell/filemgr.hxx » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698