Adium

Changeset 24182

Show
Ignore:
Timestamp:
07/02/2008 04:13:36 PM (6 months ago)
Author:
sholt
Message:

Reverting r24166, which effectively returns the full r24146 commit, restoring the reentrant flex scanner. Closes #24146.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.h

    r24166 r24182  
    2828#import "AHLinkLexer.h" 
    2929 
    30 extern long AHleng; 
    31 extern long AHlex(); 
     30typedef void* yyscan_t; 
     31 
     32extern long AHlex( yyscan_t yyscanner ); 
     33extern long AHlex_init( yyscan_t * ptr_yy_globals ); 
     34extern long AHlex_destroy ( yyscan_t yyscanner ); 
     35extern long AHget_leng ( yyscan_t scanner ); 
     36extern void AHset_in ( FILE * in_str , yyscan_t scanner ); 
     37 
    3238typedef struct AH_buffer_state *AH_BUFFER_STATE; 
    33 void AH_switch_to_buffer(AH_BUFFER_STATE); 
    34 AH_BUFFER_STATE AH_scan_string (const char *); 
    35 void AH_delete_buffer(AH_BUFFER_STATE); 
     39extern void AH_switch_to_buffer(AH_BUFFER_STATE, yyscan_t scanner); 
     40extern AH_BUFFER_STATE AH_scan_string (const char *, yyscan_t scanner); 
     41extern void AH_delete_buffer(AH_BUFFER_STATE, yyscan_t scanner); 
    3642 
    3743@class AHMarkedHyperlink; 
  • trunk/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m

    r24166 r24182  
    107107+ (BOOL)isStringValidURI:(NSString *)inString usingStrict:(BOOL)useStrictChecking fromIndex:(unsigned long *)index withStatus:(AH_URI_VERIFICATION_STATUS *)validStatus 
    108108{ 
    109     AH_BUFFER_STATE buf;  // buffer for flex to scan from 
     109    AH_BUFFER_STATE      buf;  // buffer for flex to scan from 
     110        yyscan_t                 scanner; // pointer to the flex scanner opaque type 
    110111        const char              *inStringEnc; 
    111112    unsigned long        encodedLength; 
    112         static NSLock   *linkLock = nil; 
    113          
    114          
    115         if(!linkLock) 
    116                 linkLock = [[NSLock alloc] init]; 
    117         [linkLock lock]; 
    118          
     113 
    119114        if(!validStatus){ 
    120115                AH_URI_VERIFICATION_STATUS newStatus = AH_URL_INVALID; 
     
    130125 
    131126        if (!(inStringEnc = [inString cStringUsingEncoding:stringEnc])) { 
    132                 [linkLock unlock]; 
    133127                return NO; 
    134128        } 
     
    138132     
    139133        // initialize the buffer (flex automatically switches to the buffer in this function) 
    140     buf = AH_scan_string(inStringEnc); 
     134        AHlex_init(&scanner); 
     135    buf = AH_scan_string(inStringEnc, scanner); 
    141136 
    142137    // call flex to parse the input 
    143     *validStatus = AHlex(); 
    144         if(index) *index += AHleng
     138    *validStatus = AHlex(scanner); 
     139        if(index) *index += AHget_leng(scanner)
    145140         
    146141    // condition for valid URI's 
    147142    if(*validStatus == AH_URL_VALID || *validStatus == AH_MAILTO_VALID || *validStatus == AH_FILE_VALID){ 
    148         AH_delete_buffer(buf); //remove the buffer from flex. 
     143        AH_delete_buffer(buf, scanner); //remove the buffer from flex. 
    149144        buf = NULL; //null the buffer pointer for safty's sake. 
    150145         
    151146        // check that the whole string was matched by flex. 
    152147        // this prevents silly things like "blah...com" from being seen as links 
    153         if(AHleng == encodedLength){ 
    154                         [linkLock unlock]
     148        if(AHget_leng(scanner) == encodedLength){ 
     149                        AHlex_destroy(scanner)
    155150            return YES; 
    156151        } 
    157152    // condition for degenerate URL's (A.K.A. URI's sans specifiers), requres strict checking to be NO. 
    158153    }else if((*validStatus == AH_URL_DEGENERATE || *validStatus == AH_MAILTO_DEGENERATE) && !useStrictChecking){ 
    159         AH_delete_buffer(buf); 
     154        AH_delete_buffer(buf, scanner); 
    160155        buf = NULL; 
    161         if(AHleng == encodedLength){ 
    162                         [linkLock unlock]
     156        if(AHget_leng(scanner) == encodedLength){ 
     157                        AHlex_destroy(scanner)
    163158            return YES; 
    164159        } 
    165160    // if it ain't vaild, and it ain't degenerate, then it's invalid. 
    166161    }else{ 
    167         AH_delete_buffer(buf); 
     162        AH_delete_buffer(buf, scanner); 
    168163        buf = NULL; 
    169                 [linkLock unlock]
     164                AHlex_destroy(scanner)
    170165        return NO; 
    171166    } 
    172167    // default case, if the range checking above fails. 
    173         [linkLock unlock]
     168        AHlex_destroy(scanner)
    174169    return NO; 
    175170} 
  • trunk/Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.h

    r24166 r24182  
    3434    AH_MAILTO_DEGENERATE 
    3535} AH_URI_VERIFICATION_STATUS; 
     36 
     37#define YY_EXTRA_TYPE unsigned int 
  • trunk/Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.l

    r24166 r24182  
    4343 *                                                                                        without a costly call to yymore(). 
    4444 */ 
    45 long AHValidShift = 0; 
    4645#include "AHLinkLexer.h" 
    4746%} 
     
    8988ignoreable      (b\.sc|m\.in) 
    9089 
    91 %option noyywrap nounput 8bit caseless never-interactive prefix="AH" 
     90%option noyywrap nounput 8bit caseless never-interactive reentrant warn prefix="AH" 
    9291 
    9392%x CANONICAL 
    9493%% 
    9594 
    96 <CANONICAL>({userAndPass}@)?{urlCSpec}|{ipURL}|{ipv6URL} {AHleng += AHValidShift
     95<CANONICAL>({userAndPass}@)?{urlCSpec}|{ipURL}|{ipv6URL} {yyleng += yyextra
    9796                                                          BEGIN INITIAL; 
    9897                                                          return AH_URL_VALID;} 
     
    124123notes:\/\/              | 
    125124gopher:\/\/             | 
    126 x-man-page:\/\/         {AHValidShift = AHleng; BEGIN CANONICAL;} 
     125x-man-page:\/\/         {yyextra = yyleng; BEGIN CANONICAL;} 
    127126 
    128127mailto:{mailSpec}       {return AH_MAILTO_VALID;}