Adium

Changeset 24166

Show
Ignore:
Timestamp:
07/01/2008 08:08:31 PM (5 months ago)
Author:
sholt
Message:

Keeping the API changes to AutoHyperlinks, but backing out the reentrant flex option.
We lose some performance, and NSLock is back, but it will build on Xcode 2.5 with the default flex 2.5.4.

Revert this change when we figure out how to build with flex 2.5.33 on OS X 10.4.

Files:

Legend:

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

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

    r24146 r24166  
    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 
    110         yyscan_t                 scanner; // pointer to the flex scanner opaque type 
     109    AH_BUFFER_STATE buf;  // buffer for flex to scan from 
    111110        const char              *inStringEnc; 
    112111    unsigned long        encodedLength; 
    113  
     112        static NSLock   *linkLock = nil; 
     113         
     114         
     115        if(!linkLock) 
     116                linkLock = [[NSLock alloc] init]; 
     117        [linkLock lock]; 
     118         
    114119        if(!validStatus){ 
    115120                AH_URI_VERIFICATION_STATUS newStatus = AH_URL_INVALID; 
     
    125130 
    126131        if (!(inStringEnc = [inString cStringUsingEncoding:stringEnc])) { 
     132                [linkLock unlock]; 
    127133                return NO; 
    128134        } 
     
    132138     
    133139        // initialize the buffer (flex automatically switches to the buffer in this function) 
    134         AHlex_init(&scanner); 
    135     buf = AH_scan_string(inStringEnc, scanner); 
     140    buf = AH_scan_string(inStringEnc); 
    136141 
    137142    // call flex to parse the input 
    138     *validStatus = AHlex(scanner); 
    139         if(index) *index += AHget_leng(scanner)
     143    *validStatus = AHlex(); 
     144        if(index) *index += AHleng
    140145         
    141146    // condition for valid URI's 
    142147    if(*validStatus == AH_URL_VALID || *validStatus == AH_MAILTO_VALID || *validStatus == AH_FILE_VALID){ 
    143         AH_delete_buffer(buf, scanner); //remove the buffer from flex. 
     148        AH_delete_buffer(buf); //remove the buffer from flex. 
    144149        buf = NULL; //null the buffer pointer for safty's sake. 
    145150         
    146151        // check that the whole string was matched by flex. 
    147152        // this prevents silly things like "blah...com" from being seen as links 
    148         if(AHget_leng(scanner) == encodedLength){ 
    149                         AHlex_destroy(scanner)
     153        if(AHleng == encodedLength){ 
     154                        [linkLock unlock]
    150155            return YES; 
    151156        } 
    152157    // condition for degenerate URL's (A.K.A. URI's sans specifiers), requres strict checking to be NO. 
    153158    }else if((*validStatus == AH_URL_DEGENERATE || *validStatus == AH_MAILTO_DEGENERATE) && !useStrictChecking){ 
    154         AH_delete_buffer(buf, scanner); 
     159        AH_delete_buffer(buf); 
    155160        buf = NULL; 
    156         if(AHget_leng(scanner) == encodedLength){ 
    157                         AHlex_destroy(scanner)
     161        if(AHleng == encodedLength){ 
     162                        [linkLock unlock]
    158163            return YES; 
    159164        } 
    160165    // if it ain't vaild, and it ain't degenerate, then it's invalid. 
    161166    }else{ 
    162         AH_delete_buffer(buf, scanner); 
     167        AH_delete_buffer(buf); 
    163168        buf = NULL; 
    164                 AHlex_destroy(scanner)
     169                [linkLock unlock]
    165170        return NO; 
    166171    } 
    167172    // default case, if the range checking above fails. 
    168         AHlex_destroy(scanner)
     173        [linkLock unlock]
    169174    return NO; 
    170175} 
  • trunk/Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.h

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

    r24146 r24166  
    4343 *                                                                                        without a costly call to yymore(). 
    4444 */ 
     45long AHValidShift = 0; 
    4546#include "AHLinkLexer.h" 
    4647%} 
     
    8889ignoreable      (b\.sc|m\.in) 
    8990 
    90 %option noyywrap nounput 8bit caseless never-interactive reentrant warn prefix="AH" 
     91%option noyywrap nounput 8bit caseless never-interactive prefix="AH" 
    9192 
    9293%x CANONICAL 
    9394%% 
    9495 
    95 <CANONICAL>({userAndPass}@)?{urlCSpec}|{ipURL}|{ipv6URL} {yyleng += yyextra
     96<CANONICAL>({userAndPass}@)?{urlCSpec}|{ipURL}|{ipv6URL} {AHleng += AHValidShift
    9697                                                          BEGIN INITIAL; 
    9798                                                          return AH_URL_VALID;} 
     
    123124notes:\/\/              | 
    124125gopher:\/\/             | 
    125 x-man-page:\/\/         {yyextra = yyleng; BEGIN CANONICAL;} 
     126x-man-page:\/\/         {AHValidShift = AHleng; BEGIN CANONICAL;} 
    126127 
    127128mailto:{mailSpec}       {return AH_MAILTO_VALID;}