#4 altlinuxHyph added code

closed-fixed
nobody
None
5
2010-03-04
2007-05-24
Jose Da Silva
No

Some suggested code for substring.c.
Add what looks okay, leave-out what doesn't seem okay.

1) Moved messages to one area - should allow for messages to be re-used. Could possibly add other languages by using #ifdef (hard-coded) or by inserting messages into arrays (load on demand).

2) Used << and >> for CPUs that don't have a divide or multiply (less code, plus faster for some CPUs).

3) Added a possible suggested way of dealing with UTF-8 at lines 42/43/44 by using if (c>=0)
Maybe better to code as if (c>=0 && ascii8bit) where ascii8bit=0 for UTF-8 and !=0 for ISO-885x text.

Discussion

  • Jose Da Silva
    Jose Da Silva
    2007-05-24

    some improvements and fixes for substring.c

     
    Attachments
    • status: open --> pending
     
  • Logged In: YES
    user_id=726595
    Originator: NO

    Hi, it would be nice to post the substring.c patch to its author, too. Unfortunatelly, I have no time to check your patch. The preferred way to precompile LibHnj hyphenation patterns is using substrings.pl for its Unicode and non-standard hyphenation support (but the C version would be useful for a loading time preprocessing.)

     
  • Jose Da Silva
    Jose Da Silva
    2007-06-14

    • status: pending --> open
     
  • Jose Da Silva
    Jose Da Silva
    2007-06-14

    Logged In: YES
    user_id=1138138
    Originator: YES

    Okay - good suggestion.
    1 email pointing to this webpage and patch have been sent to Raph Levien using email address at bottom of page of www.levien.com

    2nd email to Nanning Buitenhuis (substrings.c) mentioned in the authors section.

     
  • patch is quite old now, FWIW though
    Any half way right compiler would optimize /2 *2 into shifts
    fgets returns NULL on error, so comparison > 0 wouldn't be ideal
    fprintf returns number of chars written so comparison against !0 causing a failure isn't ideal either
    worth checking the nulls of course, so added that in

     
    • status: open --> closed-fixed