home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / StringConversion2.tops < prev    next >
Encoding:
Text File  |  1996-03-28  |  57.0 KB  |  1,153 lines

  1.  
  2. /* NOTE:  Read the comment about duplication below after the ctype rules.  */
  3.  
  4. /*********** StringConversion: warn about ansi/ctype.h calls and make suggestions about changes ***********/
  5.  
  6. replace "NXIsAlNum" with "NXIsAlNum"
  7.     warning "StringConversion2: Consider using [[NSCharacterSet alphanumericCharacterSet] characterIsMember:x] instead of NXIsAlNum(x)"
  8.  
  9. replace "NXIsAscii" with "NXIsAscii"
  10.     warning "StringConversion2: Consider using [[NSCharacterSet characterSetWithRange:NSMakeRange(0,128)] characterIsMember:x] instead of NXIsAscii(x)"
  11.  
  12. replace "NXIsDigit" with "NXIsDigit"
  13.     warning "StringConversion2: Consider using [NSCharacterSet decimalDigitCharacterSet] characterIsMember:x] instead of NXIsDigit(x)"
  14.  
  15. replace "NXIsLower" with "NXIsLower"
  16.     warning "StringConversion2: Consider using [NSCharacterSet lowercaseLetterCharacterSet] characterIsMember:x] instead of NXIsLower(x); Note that (not-lower && is-alpha) does not mean is-upper."
  17.  
  18. replace "NXIsPunct" with "NXIsPunct"
  19.     warning "StringConversion2: Consider using (!([[NSCharacterSet alphanumericCharacterSet] characterIsMember:x] || [[NSCharacterSet letterCharacterSet] characterIsMember:x])) instead of NXIsPunct(x)"
  20.  
  21. replace "NXIsUpper" with "NXIsUpper"
  22.     warning "StringConversion2: Consider using [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:x] instead of NXIsUpper(x); Note that (not-upper && is-alpha) does not mean is-lower"
  23.  
  24. replace "NXIsAlpha" with "NXIsAlpha"
  25.     warning "StringConversion2: Consider using [[NSCharacterSet letterCharacterSet] characterIsMember:x] instead of NXIsAlpha(x)"
  26.  
  27. replace "NXIsCntrl" with "NXIsCntrl"
  28.     warning "StringConversion2: Consider using [[NSCharacterSet controlCharacterSet] characterIsMember:x] instead of NXIsCntrl(x)"
  29.  
  30. replace "NXIsGraph" with "NXIsGraph"
  31.     warning "StringConversion2: Consider using (![[NSCharacterSet controlCharacterSet] characterIsMember:x]) instead of NXIsGraph(x)"
  32.  
  33. replace "NXIsPrint" with "NXIsPrint"
  34.     warning "StringConversion2: Consider using (![[NSCharacterSet controlCharacterSet] characterIsMember:x]) instead of NXIsPrint(x)"
  35.  
  36. replace "NXIsSpace" with "NXIsSpace"
  37.     warning "StringConversion2: Consider using [[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:x] instead of NXIsSpace(x)"
  38.  
  39. replace "NXIsXDigit" with "NXIsXDigit"
  40.     warning "StringConversion2: Consider using [[NSCharacterSet characterSetWithCharactersInString:@\"0123456789ABCDEFabcdef\"] characterIsMember:x] instead of NXIsXDigit(x)."
  41.  
  42. replace "NXToAscii" with "NXToAscii"
  43.     warning "StringConversion2: Consider conversion to the encoding NSASCIIStringEncoding or NSNonLossyASCIIStringEncoding using an NSString method instead of NXToAscii()"
  44.  
  45. replace "NXToUpper" with "NXToUpper"
  46.     warning "StringConversion2: Consider conversion using the NSString method 'uppercaseString' method instead of NXToUpper()."
  47.  
  48. replace "NXToLower" with "NXToLower"
  49.     warning "StringConversion2: Consider conversion using the NSString method 'lowercaseString' method instead of NXToLower()."
  50.  
  51.  
  52.  
  53. replace "[<aString> cString] = <anotherString>;" with "<aString> = [NSString stringWithCString:<anotherString>];"
  54.  
  55. /* NOTE:  The contents of this whole script are duplicated twice because the propagation of NSString type back to variable decls sometimes allows second and third order conversions.  */
  56.  
  57. /*********** StringConversion: propagate NSString types up to variable decls ***********/
  58.  
  59. replace "{<w w1>}" with "{<w w1>CONVERSION_EMPTYMETHOD}"
  60.  
  61. /* Prevent char buffers used in read() calls from being changed to NSStrings. */
  62. replace "{<w w1><b imp><w w2>}" with same
  63.     within ("<imp>") {
  64.     replace "<any imp1><w w3>read(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONread(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>"
  65.         within ("<imp1>") {
  66.         /* char ..., NSString; */
  67.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  68.         }
  69.         within ("<imp2>") {
  70.         /* char ..., NSString; */
  71.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  72.         }
  73.     }
  74. replace "CONVERSIONread" with "read"
  75.  
  76. /* Prevent char buffers used in NXRead() calls from being changed to NSStrings. */
  77. replace "{<w w1><b imp><w w2>}" with same
  78.     within ("<imp>") {
  79.     replace "<any imp1><w w3>NXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>"
  80.         within ("<imp1>") {
  81.         /* char ..., NSString; */
  82.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  83.         }
  84.         within ("<imp2>") {
  85.         /* char ..., NSString; */
  86.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  87.         }
  88.     }
  89. replace "CONVERSIONNXRead" with "NXRead"
  90.  
  91. /* Prevent char buffers used in gets() calls from being changed to NSStrings. */
  92. replace "{<w w1><b imp><w w2>}" with same
  93.     within ("<imp>") {
  94.     replace "<any imp1><w w3>gets(<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>)<w w4><any imp2>"
  95.         within ("<imp1>") {
  96.         /* char ..., NSString; */
  97.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  98.         }
  99.         within ("<imp2>") {
  100.         /* char ..., NSString; */
  101.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  102.         }
  103.     }
  104. replace "CONVERSIONgets" with "gets"
  105.  
  106. /* Prevent char buffers used in fgets() calls from being changed to NSStrings. */
  107. replace "{<w w1><b imp><w w2>}" with same
  108.     within ("<imp>") {
  109.     replace "<any imp1><w w3>fgets(<aString>, <count>, <stream>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>, <count>, <stream>)<w w4><any imp2>"
  110.         within ("<imp1>") {
  111.         /* char ..., NSString; */
  112.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  113.         }
  114.         within ("<imp2>") {
  115.         /* char ..., NSString; */
  116.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  117.         }
  118.     }
  119. replace "CONVERSIONfgets" with "fgets"
  120.  
  121. /* this is necessary because tops won't do "<any imp1><w w3><t aString>++" */
  122. replace "<w w1><t aString><w w2>++" with "(CONVERSIONPOSTPLUSPLUS(<w w1><aString><w w2>))"
  123. replace "<w w1><t aString><w w2>--" with "(CONVERSIONPOSTMINUSMINUS(<w w1><aString><w w2>))"
  124.  
  125. /* Prevent char pointers that are post incremented from being changed to NSStrings. */
  126. replace "{<w w1><b imp><w w2>}" with same
  127.     within ("<imp>") {
  128.         replace "<any imp1><w w3>CONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>"
  129.             within ("<imp1>") {
  130.                 /* char ..., NSString; */
  131.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  132.             }
  133.             within ("<imp2>") {
  134.                 /* char ..., NSString; */
  135.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  136.             }
  137.     }
  138. replace "(CONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  139. replace "(NOCONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  140.  
  141. /* Prevent char pointers that are pre incremented from being changed to NSStrings. */
  142. replace "{<w w1><b imp><w w2>}" with same
  143.     within ("<imp>") {
  144.         replace "<any imp1><w w3>++<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREPLUSPLUS(<w w5><aString>))<w w4><any imp2>"
  145.             within ("<imp1>") {
  146.                 /* char ..., NSString; */
  147.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  148.             }
  149.             within ("<imp2>") {
  150.                 /* char ..., NSString; */
  151.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  152.             }
  153.     }
  154. replace "(CONVERSIONPREPLUSPLUS(<w w5><t aString>))" with "++<w w5><aString>"
  155.  
  156. /* Prevent char pointers that are post decremented from being changed to NSStrings. */
  157. replace "{<w w1><b imp><w w2>}" with same
  158.     within ("<imp>") {
  159.         replace "<any imp1><w w3>CONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>"
  160.             within ("<imp1>") {
  161.                 /* char ..., NSString; */
  162.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  163.             }
  164.             within ("<imp2>") {
  165.                 /* char ..., NSString; */
  166.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  167.             }
  168.     }
  169. replace "(CONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  170. replace "(NOCONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  171.  
  172. /* Prevent char pointers that are pre decremented from being changed to NSStrings. */
  173. replace "{<w w1><b imp><w w2>}" with same
  174.     within ("<imp>") {
  175.         replace "<any imp1><w w3>--<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREMINUSMINUS(<w w5><aString>))<w w4><any imp2>"
  176.             within ("<imp1>") {
  177.                 /* char ..., NSString; */
  178.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  179.             }
  180.             within ("<imp2>") {
  181.                 /* char ..., NSString; */
  182.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  183.             }
  184.     }
  185. replace "(CONVERSIONPREMINUSMINUS(<w w5><t aString>))" with "--<w w5><aString>"
  186.  
  187. /* mark char* vars used in stringWithCString for conversion to NSStrings */
  188. /* In the first replace, stringWithCString is replaced by CONVERSIONstringWithCString to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  189. replace "{<w w1><b imp><w w2>}" with same
  190.     within ("<imp>") {
  191.     replace "<any imp1><w w3>[NSString stringWithCString:<aString>]<w w4><any imp2>" with "<any imp1><w w3>[NSString CONVERSIONstringWithCString:<aString>]<w w4><any imp2>"
  192.         within ("<imp1>") {
  193.         /* char ..., NSString; */
  194.         replace "char <b stuff>, *<aString>;" with "char <b stuff>; CONVERSIONNSString( *<aString>);"
  195.         replace "char <b stuff>, *<aString> = <val>;" with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  196.         replace "char <b stuff>, <aString>[<len>];" with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\";"
  197.  
  198.         /* char ..., NSString, char ...; */
  199.         replace "char <b stuff>, *<aString>," with "char <b stuff>; CONVERSIONNSString( *<aString>); char"
  200.         replace "char <b stuff>, *<aString> = <val>," with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  201.         replace "char <b stuff>, <aString>[<len>]," with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\"; char"
  202.         
  203.         /* NSString; */
  204.         replace "char *<aString>;" with "CONVERSIONNSString( *<aString>);"
  205.         replace "char *<aString>," with "CONVERSIONNSString( *<aString>); char"
  206.         replace "char *<aString> = <val>;" with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  207.         replace "char *<aString> = <val>," with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  208.         replace "char <aString>[<len>];" with "CONVERSIONNSString( *<aString>);"
  209.         replace "char <aString>[<len>]," with "CONVERSIONNSString( *<aString>),"
  210.  
  211.         replace "const CONVERSIONNSString" with "CONVERSIONNSString"
  212.         }
  213.     }
  214.  
  215. replace "NOCONVERSIONstringWithCString" with "stringWithCString"
  216. replace "CONVERSIONstringWithCString" with "stringWithCString"
  217.  
  218. replace "; CONVERSIONNSString( *<aString>)" with ";
  219.     CONVERSIONNSString( *<aString>)"
  220.  
  221. replace "CONVERSIONNSString( *<aString>); char" with "CONVERSIONNSString *<aString>;
  222.     char"
  223.  
  224. replace "CONVERSIONNSString( *<aString>) = <aStringExp>; char" with "CONVERSIONNSString *<aString> = <aStringExp>;
  225.     char"
  226.  
  227. /* strip parens in this rule to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  228. replace "{<w w1><b imp><w w2>}" with same
  229.     within ("<imp>") {
  230.     replace "<any imp1><w w3>CONVERSIONNSString( *<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNSString *<aString><w w4><any imp2>"
  231.         within ("<imp2>") {
  232.         replace "<aString>" with "[<aString> cString]"
  233.         }
  234.     }
  235.  
  236. replace "CONVERSIONNSString( *<aString>)" with "CONVERSIONNSString *<aString>"
  237.  
  238. replace "CONVERSIONNSString" with "NSString"
  239.  
  240. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  241.  
  242. /*********** StringConversion: ANSI str routines and NXCopyStringBuffer ***********/
  243. /******** NOTE: duplicated in StringConversion.tops *********/
  244.  
  245. replace "sprintf([<str1> cString], <format>)" with "<str1> = [NSString stringWithCString:<format>]"
  246.     
  247. replace "sprintf([<str1> cString], <format>, <b args>)" with "<str1> = [NSString stringWithFormat:[NSString stringWithCString:<format>], <b args>]"
  248.  
  249. replace "strcat([<str1> cString], <str2>)" with "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]"
  250.  
  251. replace "strncat([<str1> cString], <str2>, <len>)" with "<str1> = [<str1> stringByAppendingString:[[NSString stringWithCString:<str2>] substringToIndex:<len> - 1]]"
  252.  
  253. replace "strcmp([<str1> cString], <str2>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  254.   
  255. replace "strcmp(<str1>, [<str2> cString])" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  256.   
  257. replace "strcmp([<str1> cString], [<str2> cString]) == 0" with "[<str1> isEqualToString:<str2>]"
  258.  
  259. replace "!strcmp([<str1> cString], [<str2> cString])" with "[<str1> isEqualToString:<str2>]"
  260.  
  261. replace "!(strcmp([<str1> cString], [<str2> cString]))" with "[<str1> isEqualToString:<str2>]"
  262.  
  263. replace "(strcmp([<str1> cString], [<str2> cString]))" with "(![<str1> isEqualToString:<str2>])"
  264.  
  265. replace "strcmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2>]"
  266.  
  267. /* strncmp assumes prefix search */
  268. replace "strncmp([<str1> cString], <str2>, <length>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  269.   
  270. replace "strncmp(<str1>, [<str2> cString], <length>)" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  271.   
  272. replace "strncmp([<str1> cString], [<str2> cString], <length>) == 0" with "[<str1> hasPrefix:<str2>]"
  273.  
  274. replace "!strncmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> hasPrefix:<str2>]"
  275.  
  276. replace "!(strncmp([<str1> cString], [<str2> cString], <length>))" with "[<str1> hasPrefix:<str2>]"
  277.  
  278. replace "(strncmp([<str1> cString], [<str2> cString], <length>))" with "(![<str1> hasPrefix:<str2>])"
  279.  
  280. replace "strcasecmp([<str1> cString], <str2>)" with "strcasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  281.   
  282. replace "strcasecmp(<str1>, [<str2> cString])" with "strcasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  283.   
  284. replace "strcasecmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch]"
  285.  
  286. /* strncasecmp assumes prefix search */
  287. replace "strncasecmp([<str1> cString], <str2>, <length>)" with "strncasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  288.   
  289. replace "strncasecmp(<str1>, [<str2> cString], <length>)" with "strncasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  290.   
  291. replace "strncasecmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch range:NSMakeRange(0, <length>)]"
  292.  
  293. replace "strlen([<str1> cString]) == 0" with "[<str1> isEqualToString:@\"\"]"
  294.  
  295. replace "!strlen([<str1> cString])" with "[<str1> isEqualToString:@\"\"]"
  296.  
  297. replace "strlen([<str1> cString])" with "[<str1> length]"
  298.  
  299. replace "strcpy([<str1> cString], [<str2> cString])" with "<str1> = <str2>"
  300.     warning "StringConversion: This assignment of NSStrings used to be a strcpy(). With NStrings this is usually what you want because they are immutable.  However, you may need to replace <str2> with [<str2> copy] or [[<str2> copy] autorelease]."
  301. replace "strcpy([<str1> cString], <str2>)" with "<str1> = [NSString stringWithCString:<str2>]"
  302.  
  303. replace "strncpy([<str1> cString], <str2>, <length>)" with "<str1> = [[NSString stringWithCString:<str2>] substringToIndex:<length> - 1]"
  304.  
  305. replace "[<str1> cString] = NXCopyStringBuffer([<str2> cString])" with "<str1> = [<str2> copy]"
  306.  
  307. replace "[<str1> cString] = NXCopyStringBufferFromZone([<str2> cString], <zone>)" with "<str1> = [<str2> copyWithZone:<zone>]"
  308.  
  309.  
  310. /*********** StringConversion: a couple extra combinations ***********/
  311.  
  312. replace "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [<str1> stringByAppendingFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  313.  
  314. replace "<str1> = [NSString stringWithCString:<str2>]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [NSString stringWithFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  315.  
  316.  
  317. /*********** StringConversion: boolean expressions ***********/
  318. /********* NOTE: duplicated in StringConversion.tops *********/
  319.  
  320. /* some of these might not remain valid for deep conversions */
  321. replace "if ([<str1> cString])" with "if (<str1>)"
  322.  
  323. replace "([<str1> cString] &&" with "(<str1> &&"
  324.  
  325. replace "([<str1> cString] ||" with "(<str1> ||"
  326.  
  327. replace "&& [<str1> cString]" with "&& <str1>"
  328.  
  329. replace "|| [<str1> cString]" with "|| <str1>"
  330.  
  331. replace "![<str1> cString]" with "!<str1>"
  332.  
  333. replace "!*[<str1> cString]" with "[<str1> isEqualToString:@\"\"]"
  334.  
  335. replace "*[<str1> cString] == '\0'" with "[<str1> isEqualToString:@\"\"]"
  336.  
  337. replace "*[<str1> cString] != '\0'" with "![<str1> isEqualToString:@\"\"]"
  338.  
  339. replace "*[<str1> cString] == 0" with "[<str1> isEqualToString:@\"\"]"
  340.  
  341. replace "*[<str1> cString] != 0" with "![<str1> isEqualToString:@\"\"]"
  342.  
  343. replace "&& *[<str1> cString]" with "&& ![<str1> isEqualToString:@\"\"]"
  344.  
  345. replace "|| *[<str1> cString]" with "|| ![<str1> isEqualToString:@\"\"]"
  346.  
  347. replace "if (*[<str1> cString]" with "if(![<str1> isEqualToString:@\"\"]"
  348.  
  349. replace "![<str1> isEqualToString:@\"\"] && ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  350.  
  351. replace "![<str1> isEqualToString:@\"\"] || ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  352.  
  353. replace "[<str1> isEqualToString:@\"\"] && [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  354.  
  355. replace "[<str1> isEqualToString:@\"\"] || [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  356.  
  357. /*********** StringConversion: cleanup ***********/
  358. /********* NOTE: duplicated in StringConversion.tops *********/
  359.  
  360. replace "[NSString stringWithCString:<boolexp> ? <iftrue> : <iffalse>]" with "<boolexp> ? [NSString stringWithCString:<iftrue>] : [NSString stringWithCString:<iffalse>]" /* ??? */
  361.  
  362. replace "[<aString> cString] ?" with "<aString> ?"
  363.  
  364. replace "[<aString> cString] = <anotherString>;" with "<aString> = [NSString stringWithCString:<anotherString>];"
  365.  
  366. replace "[NSString stringWithCString:[NSString stringWithCString:<aString>]]" with "[NSString stringWithCString:<aString>]"
  367.  
  368. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  369.  
  370. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  371.  
  372. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  373.  
  374. replace "[NSString stringWithCString:(char *)[<aString> cString]]" with "<aString>"
  375.  
  376. replace "[NSString stringWithCString:(const char *)[<aString> cString]]" with "<aString>"
  377.  
  378. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  379.  
  380. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  381.  
  382. replace "[@<string stringconst> cString]" with "<string stringconst>"
  383.  
  384. replace "[<aString> cString][0] = '\0'" with "<aString> = @\"\""
  385.  
  386. replace "*[<aString> cString] = '\0'" with "<aString> = @\"\""
  387.  
  388. replace "extern NXAtom [<aString> cString]" with "extern NSString *<aString>"
  389.  
  390. replace "extern NSString *[<aString> cString]" with "extern NSString *<aString>"
  391.  
  392. replace "extern char *[<aString> cString]" with "extern NSString *<aString>"
  393.  
  394. replace "extern const char *[<aString> cString]" with "extern NSString *<aString>"
  395.  
  396. replace "free([<aString> cString])" with "[<aString> release]"
  397.  
  398. replace "@<string str1><w w><string str2>" with "@<string str1><w w>@<string str2>"
  399.  
  400. /*********** StringConversion: more cleanup ***********/
  401.  
  402. replace "[NSString stringWithCString:NULL]" with "nil" /* ??? */
  403.  
  404. replace "[NSString stringWithCString:nil]" with "nil" /* ??? */
  405.  
  406. replace "CONVERSION_EMPTYMETHOD" with ""
  407.  
  408. replace ":<anExp> [<aString> cString]]" with ":<anExp> <aString>]"
  409.  
  410. replace "[<anExp> [<aString> cString]]" with "[<anExp> <aString>]"
  411.  
  412. replace ":<anExp> [<aString> cString]:" with ":<anExp> <aString>:"
  413.  
  414. replace "[<anExp> [<aString> cString]:" with "[<anExp> <aString>:"
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423. /* This is a repeat of the above part of the file */
  424. /* NOTE:  The contents of this whole script are duplicated twice because the propagation of NSString type back to variable decls sometimes allows second and third order conversions.  */
  425.  
  426. /*********** StringConversion: propagate NSString types up to variable decls ***********/
  427.  
  428. replace "{<w w1>}" with "{<w w1>CONVERSION_EMPTYMETHOD}"
  429.  
  430. /* Prevent char buffers used in read() calls from being changed to NSStrings. */
  431. replace "{<w w1><b imp><w w2>}" with same
  432.     within ("<imp>") {
  433.     replace "<any imp1><w w3>read(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONread(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>"
  434.         within ("<imp1>") {
  435.         /* char ..., NSString; */
  436.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  437.         }
  438.         within ("<imp2>") {
  439.         /* char ..., NSString; */
  440.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  441.         }
  442.     }
  443. replace "CONVERSIONread" with "read"
  444.  
  445. /* Prevent char buffers used in NXRead() calls from being changed to NSStrings. */
  446. replace "{<w w1><b imp><w w2>}" with same
  447.     within ("<imp>") {
  448.     replace "<any imp1><w w3>NXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>"
  449.         within ("<imp1>") {
  450.         /* char ..., NSString; */
  451.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  452.         }
  453.         within ("<imp2>") {
  454.         /* char ..., NSString; */
  455.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  456.         }
  457.     }
  458. replace "CONVERSIONNXRead" with "NXRead"
  459.  
  460. /* Prevent char buffers used in gets() calls from being changed to NSStrings. */
  461. replace "{<w w1><b imp><w w2>}" with same
  462.     within ("<imp>") {
  463.     replace "<any imp1><w w3>gets(<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>)<w w4><any imp2>"
  464.         within ("<imp1>") {
  465.         /* char ..., NSString; */
  466.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  467.         }
  468.         within ("<imp2>") {
  469.         /* char ..., NSString; */
  470.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  471.         }
  472.     }
  473. replace "CONVERSIONgets" with "gets"
  474.  
  475. /* Prevent char buffers used in fgets() calls from being changed to NSStrings. */
  476. replace "{<w w1><b imp><w w2>}" with same
  477.     within ("<imp>") {
  478.     replace "<any imp1><w w3>fgets(<aString>, <count>, <stream>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>, <count>, <stream>)<w w4><any imp2>"
  479.         within ("<imp1>") {
  480.         /* char ..., NSString; */
  481.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  482.         }
  483.         within ("<imp2>") {
  484.         /* char ..., NSString; */
  485.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  486.         }
  487.     }
  488. replace "CONVERSIONfgets" with "fgets"
  489.  
  490. /* this is necessary because tops won't do "<any imp1><w w3><t aString>++" */
  491. replace "<w w1><t aString><w w2>++" with "(CONVERSIONPOSTPLUSPLUS(<w w1><aString><w w2>))"
  492. replace "<w w1><t aString><w w2>--" with "(CONVERSIONPOSTMINUSMINUS(<w w1><aString><w w2>))"
  493.  
  494. /* Prevent char pointers that are post incremented from being changed to NSStrings. */
  495. replace "{<w w1><b imp><w w2>}" with same
  496.     within ("<imp>") {
  497.         replace "<any imp1><w w3>CONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>"
  498.             within ("<imp1>") {
  499.                 /* char ..., NSString; */
  500.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  501.             }
  502.             within ("<imp2>") {
  503.                 /* char ..., NSString; */
  504.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  505.             }
  506.     }
  507. replace "(CONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  508. replace "(NOCONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  509.  
  510. /* Prevent char pointers that are pre incremented from being changed to NSStrings. */
  511. replace "{<w w1><b imp><w w2>}" with same
  512.     within ("<imp>") {
  513.         replace "<any imp1><w w3>++<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREPLUSPLUS(<w w5><aString>))<w w4><any imp2>"
  514.             within ("<imp1>") {
  515.                 /* char ..., NSString; */
  516.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  517.             }
  518.             within ("<imp2>") {
  519.                 /* char ..., NSString; */
  520.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  521.             }
  522.     }
  523. replace "(CONVERSIONPREPLUSPLUS(<w w5><t aString>))" with "++<w w5><aString>"
  524.  
  525. /* Prevent char pointers that are post decremented from being changed to NSStrings. */
  526. replace "{<w w1><b imp><w w2>}" with same
  527.     within ("<imp>") {
  528.         replace "<any imp1><w w3>CONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>"
  529.             within ("<imp1>") {
  530.                 /* char ..., NSString; */
  531.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  532.             }
  533.             within ("<imp2>") {
  534.                 /* char ..., NSString; */
  535.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  536.             }
  537.     }
  538. replace "(CONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  539. replace "(NOCONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  540.  
  541. /* Prevent char pointers that are pre decremented from being changed to NSStrings. */
  542. replace "{<w w1><b imp><w w2>}" with same
  543.     within ("<imp>") {
  544.         replace "<any imp1><w w3>--<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREMINUSMINUS(<w w5><aString>))<w w4><any imp2>"
  545.             within ("<imp1>") {
  546.                 /* char ..., NSString; */
  547.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  548.             }
  549.             within ("<imp2>") {
  550.                 /* char ..., NSString; */
  551.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  552.             }
  553.     }
  554. replace "(CONVERSIONPREMINUSMINUS(<w w5><t aString>))" with "--<w w5><aString>"
  555.  
  556. /* mark char* vars used in stringWithCString for conversion to NSStrings */
  557. /* In the first replace, stringWithCString is replaced by CONVERSIONstringWithCString to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  558. replace "{<w w1><b imp><w w2>}" with same
  559.     within ("<imp>") {
  560.     replace "<any imp1><w w3>[NSString stringWithCString:<aString>]<w w4><any imp2>" with "<any imp1><w w3>[NSString CONVERSIONstringWithCString:<aString>]<w w4><any imp2>"
  561.         within ("<imp1>") {
  562.         /* char ..., NSString; */
  563.         replace "char <b stuff>, *<aString>;" with "char <b stuff>; CONVERSIONNSString( *<aString>);"
  564.         replace "char <b stuff>, *<aString> = <val>;" with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  565.         replace "char <b stuff>, <aString>[<len>];" with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\";"
  566.  
  567.         /* char ..., NSString, char ...; */
  568.         replace "char <b stuff>, *<aString>," with "char <b stuff>; CONVERSIONNSString( *<aString>); char"
  569.         replace "char <b stuff>, *<aString> = <val>," with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  570.         replace "char <b stuff>, <aString>[<len>]," with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\"; char"
  571.         
  572.         /* NSString; */
  573.         replace "char *<aString>;" with "CONVERSIONNSString( *<aString>);"
  574.         replace "char *<aString>," with "CONVERSIONNSString( *<aString>); char"
  575.         replace "char *<aString> = <val>;" with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  576.         replace "char *<aString> = <val>," with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  577.         replace "char <aString>[<len>];" with "CONVERSIONNSString( *<aString>);"
  578.         replace "char <aString>[<len>]," with "CONVERSIONNSString( *<aString>),"
  579.  
  580.         replace "const CONVERSIONNSString" with "CONVERSIONNSString"
  581.         }
  582.     }
  583.  
  584. replace "NOCONVERSIONstringWithCString" with "stringWithCString"
  585. replace "CONVERSIONstringWithCString" with "stringWithCString"
  586.  
  587. replace "; CONVERSIONNSString( *<aString>)" with ";
  588.     CONVERSIONNSString( *<aString>)"
  589.  
  590. replace "CONVERSIONNSString( *<aString>); char" with "CONVERSIONNSString *<aString>;
  591.     char"
  592.  
  593. replace "CONVERSIONNSString( *<aString>) = <aStringExp>; char" with "CONVERSIONNSString *<aString> = <aStringExp>;
  594.     char"
  595.  
  596. /* strip parens in this rule to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  597. replace "{<w w1><b imp><w w2>}" with same
  598.     within ("<imp>") {
  599.     replace "<any imp1><w w3>CONVERSIONNSString( *<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNSString *<aString><w w4><any imp2>"
  600.         within ("<imp2>") {
  601.         replace "<aString>" with "[<aString> cString]"
  602.         }
  603.     }
  604.  
  605. replace "CONVERSIONNSString( *<aString>)" with "CONVERSIONNSString *<aString>"
  606.  
  607. replace "CONVERSIONNSString" with "NSString"
  608.  
  609. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  610.  
  611. /*********** StringConversion: ANSI str routines and NXCopyStringBuffer ***********/
  612. /******** NOTE: duplicated in StringConversion.tops *********/
  613.  
  614. replace "sprintf([<str1> cString], <format>)" with "<str1> = [NSString stringWithCString:<format>]"
  615.     
  616. replace "sprintf([<str1> cString], <format>, <b args>)" with "<str1> = [NSString stringWithFormat:[NSString stringWithCString:<format>], <b args>]"
  617.  
  618. replace "strcat([<str1> cString], <str2>)" with "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]"
  619.  
  620. replace "strncat([<str1> cString], <str2>, <len>)" with "<str1> = [<str1> stringByAppendingString:[[NSString stringWithCString:<str2>] substringToIndex:<len> - 1]]"
  621.  
  622. replace "strcmp([<str1> cString], <str2>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  623.   
  624. replace "strcmp(<str1>, [<str2> cString])" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  625.   
  626. replace "strcmp([<str1> cString], [<str2> cString]) == 0" with "[<str1> isEqualToString:<str2>]"
  627.  
  628. replace "!strcmp([<str1> cString], [<str2> cString])" with "[<str1> isEqualToString:<str2>]"
  629.  
  630. replace "!(strcmp([<str1> cString], [<str2> cString]))" with "[<str1> isEqualToString:<str2>]"
  631.  
  632. replace "(strcmp([<str1> cString], [<str2> cString]))" with "(![<str1> isEqualToString:<str2>])"
  633.  
  634. replace "strcmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2>]"
  635.  
  636. /* strncmp assumes prefix search */
  637. replace "strncmp([<str1> cString], <str2>, <length>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  638.   
  639. replace "strncmp(<str1>, [<str2> cString], <length>)" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  640.   
  641. replace "strncmp([<str1> cString], [<str2> cString], <length>) == 0" with "[<str1> hasPrefix:<str2>]"
  642.  
  643. replace "!strncmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> hasPrefix:<str2>]"
  644.  
  645. replace "!(strncmp([<str1> cString], [<str2> cString], <length>))" with "[<str1> hasPrefix:<str2>]"
  646.  
  647. replace "(strncmp([<str1> cString], [<str2> cString], <length>))" with "(![<str1> hasPrefix:<str2>])"
  648.  
  649. replace "strcasecmp([<str1> cString], <str2>)" with "strcasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  650.   
  651. replace "strcasecmp(<str1>, [<str2> cString])" with "strcasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  652.   
  653. replace "strcasecmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch]"
  654.  
  655. /* strncasecmp assumes prefix search */
  656. replace "strncasecmp([<str1> cString], <str2>, <length>)" with "strncasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  657.   
  658. replace "strncasecmp(<str1>, [<str2> cString], <length>)" with "strncasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  659.   
  660. replace "strncasecmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch range:NSMakeRange(0, <length>)]"
  661.  
  662. replace "strlen([<str1> cString]) == 0" with "[<str1> isEqualToString:@\"\"]"
  663.  
  664. replace "!strlen([<str1> cString])" with "[<str1> isEqualToString:@\"\"]"
  665.  
  666. replace "strlen([<str1> cString])" with "[<str1> length]"
  667.  
  668. replace "strcpy([<str1> cString], [<str2> cString])" with "<str1> = <str2>"
  669.     warning "StringConversion: This assignment of NSStrings used to be a strcpy(). With NStrings this is usually what you want because they are immutable.  However, you may need to replace <str2> with [<str2> copy] or [[<str2> copy] autorelease]."
  670. replace "strcpy([<str1> cString], <str2>)" with "<str1> = [NSString stringWithCString:<str2>]"
  671.  
  672. replace "strncpy([<str1> cString], <str2>, <length>)" with "<str1> = [[NSString stringWithCString:<str2>] substringToIndex:<length> - 1]"
  673.  
  674. replace "[<str1> cString] = NXCopyStringBuffer([<str2> cString])" with "<str1> = [<str2> copy]"
  675.  
  676. replace "[<str1> cString] = NXCopyStringBufferFromZone([<str2> cString], <zone>)" with "<str1> = [<str2> copyWithZone:<zone>]"
  677.  
  678.  
  679. /*********** StringConversion: a couple extra combinations ***********/
  680.  
  681. replace "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [<str1> stringByAppendingFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  682.  
  683. replace "<str1> = [NSString stringWithCString:<str2>]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [NSString stringWithFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  684.  
  685.  
  686. /*********** StringConversion: boolean expressions ***********/
  687. /********* NOTE: duplicated in StringConversion.tops *********/
  688.  
  689. /* some of these might not remain valid for deep conversions */
  690. replace "if ([<str1> cString])" with "if (<str1>)"
  691.  
  692. replace "([<str1> cString] &&" with "(<str1> &&"
  693.  
  694. replace "([<str1> cString] ||" with "(<str1> ||"
  695.  
  696. replace "&& [<str1> cString]" with "&& <str1>"
  697.  
  698. replace "|| [<str1> cString]" with "|| <str1>"
  699.  
  700. replace "![<str1> cString]" with "!<str1>"
  701.  
  702. replace "!*[<str1> cString]" with "[<str1> isEqualToString:@\"\"]"
  703.  
  704. replace "*[<str1> cString] == '\0'" with "[<str1> isEqualToString:@\"\"]"
  705.  
  706. replace "*[<str1> cString] != '\0'" with "![<str1> isEqualToString:@\"\"]"
  707.  
  708. replace "*[<str1> cString] == 0" with "[<str1> isEqualToString:@\"\"]"
  709.  
  710. replace "*[<str1> cString] != 0" with "![<str1> isEqualToString:@\"\"]"
  711.  
  712. replace "&& *[<str1> cString]" with "&& ![<str1> isEqualToString:@\"\"]"
  713.  
  714. replace "|| *[<str1> cString]" with "|| ![<str1> isEqualToString:@\"\"]"
  715.  
  716. replace "if (*[<str1> cString]" with "if(![<str1> isEqualToString:@\"\"]"
  717.  
  718. replace "![<str1> isEqualToString:@\"\"] && ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  719.  
  720. replace "![<str1> isEqualToString:@\"\"] || ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  721.  
  722. replace "[<str1> isEqualToString:@\"\"] && [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  723.  
  724. replace "[<str1> isEqualToString:@\"\"] || [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  725.  
  726. /*********** StringConversion: cleanup ***********/
  727. /********* NOTE: duplicated in StringConversion.tops *********/
  728.  
  729. replace "[NSString stringWithCString:<boolexp> ? <iftrue> : <iffalse>]" with "<boolexp> ? [NSString stringWithCString:<iftrue>] : [NSString stringWithCString:<iffalse>]" /* ??? */
  730.  
  731. replace "[<aString> cString] ?" with "<aString> ?"
  732.  
  733. replace "[<aString> cString] = <anotherString>;" with "<aString> = [NSString stringWithCString:<anotherString>];"
  734.  
  735. replace "[NSString stringWithCString:[NSString stringWithCString:<aString>]]" with "[NSString stringWithCString:<aString>]"
  736.  
  737. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  738.  
  739. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  740.  
  741. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  742.  
  743. replace "[NSString stringWithCString:(char *)[<aString> cString]]" with "<aString>"
  744.  
  745. replace "[NSString stringWithCString:(const char *)[<aString> cString]]" with "<aString>"
  746.  
  747. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  748.  
  749. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  750.  
  751. replace "[@<string stringconst> cString]" with "<string stringconst>"
  752.  
  753. replace "[<aString> cString][0] = '\0'" with "<aString> = @\"\""
  754.  
  755. replace "*[<aString> cString] = '\0'" with "<aString> = @\"\""
  756.  
  757. replace "extern NXAtom [<aString> cString]" with "extern NSString *<aString>"
  758.  
  759. replace "extern NSString *[<aString> cString]" with "extern NSString *<aString>"
  760.  
  761. replace "extern char *[<aString> cString]" with "extern NSString *<aString>"
  762.  
  763. replace "extern const char *[<aString> cString]" with "extern NSString *<aString>"
  764.  
  765. replace "free([<aString> cString])" with "[<aString> release]"
  766.  
  767. replace "@<string str1><w w><string str2>" with "@<string str1><w w>@<string str2>"
  768.  
  769. /*********** StringConversion: more cleanup ***********/
  770.  
  771. replace "[NSString stringWithCString:NULL]" with "nil" /* ??? */
  772.  
  773. replace "[NSString stringWithCString:nil]" with "nil" /* ??? */
  774.  
  775. replace "CONVERSION_EMPTYMETHOD" with ""
  776.  
  777. replace ":<anExp> [<aString> cString]]" with ":<anExp> <aString>]"
  778.  
  779. replace "[<anExp> [<aString> cString]]" with "[<anExp> <aString>]"
  780.  
  781. replace ":<anExp> [<aString> cString]:" with ":<anExp> <aString>:"
  782.  
  783. replace "[<anExp> [<aString> cString]:" with "[<anExp> <aString>:"
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792. /* This is a repeat of the above part of the file */
  793. /* NOTE:  The contents of this whole script are duplicated twice because the propagation of NSString type back to variable decls sometimes allows second and third order conversions.  */
  794.  
  795. /*********** StringConversion: propagate NSString types up to variable decls ***********/
  796.  
  797. replace "{<w w1>}" with "{<w w1>CONVERSION_EMPTYMETHOD}"
  798.  
  799. /* Prevent char buffers used in read() calls from being changed to NSStrings. */
  800. replace "{<w w1><b imp><w w2>}" with same
  801.     within ("<imp>") {
  802.     replace "<any imp1><w w3>read(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONread(<fd>, <aString>, <bytesToRead>)<w w4><any imp2>"
  803.         within ("<imp1>") {
  804.         /* char ..., NSString; */
  805.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  806.         }
  807.         within ("<imp2>") {
  808.         /* char ..., NSString; */
  809.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  810.         }
  811.     }
  812. replace "CONVERSIONread" with "read"
  813.  
  814. /* Prevent char buffers used in NXRead() calls from being changed to NSStrings. */
  815. replace "{<w w1><b imp><w w2>}" with same
  816.     within ("<imp>") {
  817.     replace "<any imp1><w w3>NXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNXRead(<stream>, <aString>, <bytesToRead>)<w w4><any imp2>"
  818.         within ("<imp1>") {
  819.         /* char ..., NSString; */
  820.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  821.         }
  822.         within ("<imp2>") {
  823.         /* char ..., NSString; */
  824.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  825.         }
  826.     }
  827. replace "CONVERSIONNXRead" with "NXRead"
  828.  
  829. /* Prevent char buffers used in gets() calls from being changed to NSStrings. */
  830. replace "{<w w1><b imp><w w2>}" with same
  831.     within ("<imp>") {
  832.     replace "<any imp1><w w3>gets(<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>)<w w4><any imp2>"
  833.         within ("<imp1>") {
  834.         /* char ..., NSString; */
  835.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  836.         }
  837.         within ("<imp2>") {
  838.         /* char ..., NSString; */
  839.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  840.         }
  841.     }
  842. replace "CONVERSIONgets" with "gets"
  843.  
  844. /* Prevent char buffers used in fgets() calls from being changed to NSStrings. */
  845. replace "{<w w1><b imp><w w2>}" with same
  846.     within ("<imp>") {
  847.     replace "<any imp1><w w3>fgets(<aString>, <count>, <stream>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONgets(<aString>, <count>, <stream>)<w w4><any imp2>"
  848.         within ("<imp1>") {
  849.         /* char ..., NSString; */
  850.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  851.         }
  852.         within ("<imp2>") {
  853.         /* char ..., NSString; */
  854.         replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  855.         }
  856.     }
  857. replace "CONVERSIONfgets" with "fgets"
  858.  
  859. /* this is necessary because tops won't do "<any imp1><w w3><t aString>++" */
  860. replace "<w w1><t aString><w w2>++" with "(CONVERSIONPOSTPLUSPLUS(<w w1><aString><w w2>))"
  861. replace "<w w1><t aString><w w2>--" with "(CONVERSIONPOSTMINUSMINUS(<w w1><aString><w w2>))"
  862.  
  863. /* Prevent char pointers that are post incremented from being changed to NSStrings. */
  864. replace "{<w w1><b imp><w w2>}" with same
  865.     within ("<imp>") {
  866.         replace "<any imp1><w w3>CONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTPLUSPLUS(<aString>)<w w4><any imp2>"
  867.             within ("<imp1>") {
  868.                 /* char ..., NSString; */
  869.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  870.             }
  871.             within ("<imp2>") {
  872.                 /* char ..., NSString; */
  873.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  874.             }
  875.     }
  876. replace "(CONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  877. replace "(NOCONVERSIONPOSTPLUSPLUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>++"
  878.  
  879. /* Prevent char pointers that are pre incremented from being changed to NSStrings. */
  880. replace "{<w w1><b imp><w w2>}" with same
  881.     within ("<imp>") {
  882.         replace "<any imp1><w w3>++<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREPLUSPLUS(<w w5><aString>))<w w4><any imp2>"
  883.             within ("<imp1>") {
  884.                 /* char ..., NSString; */
  885.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  886.             }
  887.             within ("<imp2>") {
  888.                 /* char ..., NSString; */
  889.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  890.             }
  891.     }
  892. replace "(CONVERSIONPREPLUSPLUS(<w w5><t aString>))" with "++<w w5><aString>"
  893.  
  894. /* Prevent char pointers that are post decremented from being changed to NSStrings. */
  895. replace "{<w w1><b imp><w w2>}" with same
  896.     within ("<imp>") {
  897.         replace "<any imp1><w w3>CONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>" with "<any imp1><w w3>NOCONVERSIONPOSTMINUSMINUS(<aString>)<w w4><any imp2>"
  898.             within ("<imp1>") {
  899.                 /* char ..., NSString; */
  900.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  901.             }
  902.             within ("<imp2>") {
  903.                 /* char ..., NSString; */
  904.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  905.             }
  906.     }
  907. replace "(CONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  908. replace "(NOCONVERSIONPOSTMINUSMINUS(<w w1><t aString><w w2>))" with "<w w1><aString><w w2>--"
  909.  
  910. /* Prevent char pointers that are pre decremented from being changed to NSStrings. */
  911. replace "{<w w1><b imp><w w2>}" with same
  912.     within ("<imp>") {
  913.         replace "<any imp1><w w3>--<w w5><t aString><w w4><any imp2>" with "<any imp1><w w3>(CONVERSIONPREMINUSMINUS(<w w5><aString>))<w w4><any imp2>"
  914.             within ("<imp1>") {
  915.                 /* char ..., NSString; */
  916.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  917.             }
  918.             within ("<imp2>") {
  919.                 /* char ..., NSString; */
  920.                 replace "[NSString stringWithCString:<aString>]" with "[NSString NOCONVERSIONstringWithCString:<aString>]"
  921.             }
  922.     }
  923. replace "(CONVERSIONPREMINUSMINUS(<w w5><t aString>))" with "--<w w5><aString>"
  924.  
  925. /* mark char* vars used in stringWithCString for conversion to NSStrings */
  926. /* In the first replace, stringWithCString is replaced by CONVERSIONstringWithCString to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  927. replace "{<w w1><b imp><w w2>}" with same
  928.     within ("<imp>") {
  929.     replace "<any imp1><w w3>[NSString stringWithCString:<aString>]<w w4><any imp2>" with "<any imp1><w w3>[NSString CONVERSIONstringWithCString:<aString>]<w w4><any imp2>"
  930.         within ("<imp1>") {
  931.         /* char ..., NSString; */
  932.         replace "char <b stuff>, *<aString>;" with "char <b stuff>; CONVERSIONNSString( *<aString>);"
  933.         replace "char <b stuff>, *<aString> = <val>;" with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  934.         replace "char <b stuff>, <aString>[<len>];" with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\";"
  935.  
  936.         /* char ..., NSString, char ...; */
  937.         replace "char <b stuff>, *<aString>," with "char <b stuff>; CONVERSIONNSString( *<aString>); char"
  938.         replace "char <b stuff>, *<aString> = <val>," with "char <b stuff>; CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  939.         replace "char <b stuff>, <aString>[<len>]," with "char <b stuff>; CONVERSIONNSString( *<aString>) = @\"\"; char"
  940.         
  941.         /* NSString; */
  942.         replace "char *<aString>;" with "CONVERSIONNSString( *<aString>);"
  943.         replace "char *<aString>," with "CONVERSIONNSString( *<aString>); char"
  944.         replace "char *<aString> = <val>;" with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>];"
  945.         replace "char *<aString> = <val>," with "CONVERSIONNSString( *<aString>) = [NSString stringWithCString:<val>]; char"
  946.         replace "char <aString>[<len>];" with "CONVERSIONNSString( *<aString>);"
  947.         replace "char <aString>[<len>]," with "CONVERSIONNSString( *<aString>),"
  948.  
  949.         replace "const CONVERSIONNSString" with "CONVERSIONNSString"
  950.         }
  951.     }
  952.  
  953. replace "NOCONVERSIONstringWithCString" with "stringWithCString"
  954. replace "CONVERSIONstringWithCString" with "stringWithCString"
  955.  
  956. replace "; CONVERSIONNSString( *<aString>)" with ";
  957.     CONVERSIONNSString( *<aString>)"
  958.  
  959. replace "CONVERSIONNSString( *<aString>); char" with "CONVERSIONNSString *<aString>;
  960.     char"
  961.  
  962. replace "CONVERSIONNSString( *<aString>) = <aStringExp>; char" with "CONVERSIONNSString *<aString> = <aStringExp>;
  963.     char"
  964.  
  965. /* strip parens in this rule to make tops believe the rule won't infinitely recurse, which allows it to match more than once. */
  966. replace "{<w w1><b imp><w w2>}" with same
  967.     within ("<imp>") {
  968.     replace "<any imp1><w w3>CONVERSIONNSString( *<aString>)<w w4><any imp2>" with "<any imp1><w w3>CONVERSIONNSString *<aString><w w4><any imp2>"
  969.         within ("<imp2>") {
  970.         replace "<aString>" with "[<aString> cString]"
  971.         }
  972.     }
  973.  
  974. replace "CONVERSIONNSString( *<aString>)" with "CONVERSIONNSString *<aString>"
  975.  
  976. replace "CONVERSIONNSString" with "NSString"
  977.  
  978. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  979.  
  980. /*********** StringConversion: ANSI str routines and NXCopyStringBuffer ***********/
  981. /******** NOTE: duplicated in StringConversion.tops *********/
  982.  
  983. replace "sprintf([<str1> cString], <format>)" with "<str1> = [NSString stringWithCString:<format>]"
  984.     
  985. replace "sprintf([<str1> cString], <format>, <b args>)" with "<str1> = [NSString stringWithFormat:[NSString stringWithCString:<format>], <b args>]"
  986.  
  987. replace "strcat([<str1> cString], <str2>)" with "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]"
  988.  
  989. replace "strncat([<str1> cString], <str2>, <len>)" with "<str1> = [<str1> stringByAppendingString:[[NSString stringWithCString:<str2>] substringToIndex:<len> - 1]]"
  990.  
  991. replace "strcmp([<str1> cString], <str2>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  992.   
  993. replace "strcmp(<str1>, [<str2> cString])" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  994.   
  995. replace "strcmp([<str1> cString], [<str2> cString]) == 0" with "[<str1> isEqualToString:<str2>]"
  996.  
  997. replace "!strcmp([<str1> cString], [<str2> cString])" with "[<str1> isEqualToString:<str2>]"
  998.  
  999. replace "!(strcmp([<str1> cString], [<str2> cString]))" with "[<str1> isEqualToString:<str2>]"
  1000.  
  1001. replace "(strcmp([<str1> cString], [<str2> cString]))" with "(![<str1> isEqualToString:<str2>])"
  1002.  
  1003. replace "strcmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2>]"
  1004.  
  1005. /* strncmp assumes prefix search */
  1006. replace "strncmp([<str1> cString], <str2>, <length>)" with "strcmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  1007.   
  1008. replace "strncmp(<str1>, [<str2> cString], <length>)" with "strcmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  1009.   
  1010. replace "strncmp([<str1> cString], [<str2> cString], <length>) == 0" with "[<str1> hasPrefix:<str2>]"
  1011.  
  1012. replace "!strncmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> hasPrefix:<str2>]"
  1013.  
  1014. replace "!(strncmp([<str1> cString], [<str2> cString], <length>))" with "[<str1> hasPrefix:<str2>]"
  1015.  
  1016. replace "(strncmp([<str1> cString], [<str2> cString], <length>))" with "(![<str1> hasPrefix:<str2>])"
  1017.  
  1018. replace "strcasecmp([<str1> cString], <str2>)" with "strcasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString])"
  1019.   
  1020. replace "strcasecmp(<str1>, [<str2> cString])" with "strcasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString])"
  1021.   
  1022. replace "strcasecmp([<str1> cString], [<str2> cString])" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch]"
  1023.  
  1024. /* strncasecmp assumes prefix search */
  1025. replace "strncasecmp([<str1> cString], <str2>, <length>)" with "strncasecmp([<str1> cString], [[NSString stringWithCString:<str2>] cString], <length>)"
  1026.   
  1027. replace "strncasecmp(<str1>, [<str2> cString], <length>)" with "strncasecmp([[NSString stringWithCString:<str1>] cString], [<str2> cString], <length>)"
  1028.   
  1029. replace "strncasecmp([<str1> cString], [<str2> cString], <length>)" with "[<str1> compare:<str2> options:NSCaseInsensitiveSearch range:NSMakeRange(0, <length>)]"
  1030.  
  1031. replace "strlen([<str1> cString]) == 0" with "[<str1> isEqualToString:@\"\"]"
  1032.  
  1033. replace "!strlen([<str1> cString])" with "[<str1> isEqualToString:@\"\"]"
  1034.  
  1035. replace "strlen([<str1> cString])" with "[<str1> length]"
  1036.  
  1037. replace "strcpy([<str1> cString], [<str2> cString])" with "<str1> = <str2>"
  1038.     warning "StringConversion: This assignment of NSStrings used to be a strcpy(). With NStrings this is usually what you want because they are immutable.  However, you may need to replace <str2> with [<str2> copy] or [[<str2> copy] autorelease]."
  1039. replace "strcpy([<str1> cString], <str2>)" with "<str1> = [NSString stringWithCString:<str2>]"
  1040.  
  1041. replace "strncpy([<str1> cString], <str2>, <length>)" with "<str1> = [[NSString stringWithCString:<str2>] substringToIndex:<length> - 1]"
  1042.  
  1043. replace "[<str1> cString] = NXCopyStringBuffer([<str2> cString])" with "<str1> = [<str2> copy]"
  1044.  
  1045. replace "[<str1> cString] = NXCopyStringBufferFromZone([<str2> cString], <zone>)" with "<str1> = [<str2> copyWithZone:<zone>]"
  1046.  
  1047.  
  1048. /*********** StringConversion: a couple extra combinations ***********/
  1049.  
  1050. replace "<str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str2>]]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [<str1> stringByAppendingFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  1051.  
  1052. replace "<str1> = [NSString stringWithCString:<str2>]; <str1> = [<str1> stringByAppendingString:[NSString stringWithCString:<str3>]]" with "<str1> = [NSString stringWithFormat:@\"%@%@\", [NSString stringWithCString:<str2>], [NSString stringWithCString:<str3>]]"
  1053.  
  1054.  
  1055. /*********** StringConversion: boolean expressions ***********/
  1056. /********* NOTE: duplicated in StringConversion.tops *********/
  1057.  
  1058. /* some of these might not remain valid for deep conversions */
  1059. replace "if ([<str1> cString])" with "if (<str1>)"
  1060.  
  1061. replace "([<str1> cString] &&" with "(<str1> &&"
  1062.  
  1063. replace "([<str1> cString] ||" with "(<str1> ||"
  1064.  
  1065. replace "&& [<str1> cString]" with "&& <str1>"
  1066.  
  1067. replace "|| [<str1> cString]" with "|| <str1>"
  1068.  
  1069. replace "![<str1> cString]" with "!<str1>"
  1070.  
  1071. replace "!*[<str1> cString]" with "[<str1> isEqualToString:@\"\"]"
  1072.  
  1073. replace "*[<str1> cString] == '\0'" with "[<str1> isEqualToString:@\"\"]"
  1074.  
  1075. replace "*[<str1> cString] != '\0'" with "![<str1> isEqualToString:@\"\"]"
  1076.  
  1077. replace "*[<str1> cString] == 0" with "[<str1> isEqualToString:@\"\"]"
  1078.  
  1079. replace "*[<str1> cString] != 0" with "![<str1> isEqualToString:@\"\"]"
  1080.  
  1081. replace "&& *[<str1> cString]" with "&& ![<str1> isEqualToString:@\"\"]"
  1082.  
  1083. replace "|| *[<str1> cString]" with "|| ![<str1> isEqualToString:@\"\"]"
  1084.  
  1085. replace "if (*[<str1> cString]" with "if(![<str1> isEqualToString:@\"\"]"
  1086.  
  1087. replace "![<str1> isEqualToString:@\"\"] && ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  1088.  
  1089. replace "![<str1> isEqualToString:@\"\"] || ![<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  1090.  
  1091. replace "[<str1> isEqualToString:@\"\"] && [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  1092.  
  1093. replace "[<str1> isEqualToString:@\"\"] || [<str1> isEqualToString:@\"\"]" with "![<str1> isEqualToString:@\"\"]"
  1094.  
  1095. /*********** StringConversion: cleanup ***********/
  1096. /********* NOTE: duplicated in StringConversion.tops *********/
  1097.  
  1098. replace "[NSString stringWithCString:<boolexp> ? <iftrue> : <iffalse>]" with "<boolexp> ? [NSString stringWithCString:<iftrue>] : [NSString stringWithCString:<iffalse>]" /* ??? */
  1099.  
  1100. replace "[<aString> cString] ?" with "<aString> ?"
  1101.  
  1102. replace "[<aString> cString] = <anotherString>;" with "<aString> = [NSString stringWithCString:<anotherString>];"
  1103.  
  1104. replace "[NSString stringWithCString:[NSString stringWithCString:<aString>]]" with "[NSString stringWithCString:<aString>]"
  1105.  
  1106. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  1107.  
  1108. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  1109.  
  1110. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  1111.  
  1112. replace "[NSString stringWithCString:(char *)[<aString> cString]]" with "<aString>"
  1113.  
  1114. replace "[NSString stringWithCString:(const char *)[<aString> cString]]" with "<aString>"
  1115.  
  1116. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  1117.  
  1118. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  1119.  
  1120. replace "[@<string stringconst> cString]" with "<string stringconst>"
  1121.  
  1122. replace "[<aString> cString][0] = '\0'" with "<aString> = @\"\""
  1123.  
  1124. replace "*[<aString> cString] = '\0'" with "<aString> = @\"\""
  1125.  
  1126. replace "extern NXAtom [<aString> cString]" with "extern NSString *<aString>"
  1127.  
  1128. replace "extern NSString *[<aString> cString]" with "extern NSString *<aString>"
  1129.  
  1130. replace "extern char *[<aString> cString]" with "extern NSString *<aString>"
  1131.  
  1132. replace "extern const char *[<aString> cString]" with "extern NSString *<aString>"
  1133.  
  1134. replace "free([<aString> cString])" with "[<aString> release]"
  1135.  
  1136. replace "@<string str1><w w><string str2>" with "@<string str1><w w>@<string str2>"
  1137.  
  1138. /*********** StringConversion: more cleanup ***********/
  1139.  
  1140. replace "[NSString stringWithCString:NULL]" with "nil" /* ??? */
  1141.  
  1142. replace "[NSString stringWithCString:nil]" with "nil" /* ??? */
  1143.  
  1144. replace "CONVERSION_EMPTYMETHOD" with ""
  1145.  
  1146. replace ":<anExp> [<aString> cString]]" with ":<anExp> <aString>]"
  1147.  
  1148. replace "[<anExp> [<aString> cString]]" with "[<anExp> <aString>]"
  1149.  
  1150. replace ":<anExp> [<aString> cString]:" with ":<anExp> <aString>:"
  1151.  
  1152. replace "[<anExp> [<aString> cString]:" with "[<anExp> <aString>:"
  1153.