tagfile.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: tagfile.cc,v 1.37.2.2 2003/12/31 16:02:30 mdz Exp $
  4. /* ######################################################################
  5. Fast scanner for RFC-822 type header information
  6. This uses a rotating buffer to load the package information into.
  7. The scanner runs over it and isolates and indexes a single section.
  8. ##################################################################### */
  9. /*}}}*/
  10. // Include Files /*{{{*/
  11. #include<config.h>
  12. #include <apt-pkg/tagfile.h>
  13. #include <apt-pkg/error.h>
  14. #include <apt-pkg/strutl.h>
  15. #include <apt-pkg/fileutl.h>
  16. #include <string>
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <apti18n.h>
  22. /*}}}*/
  23. using std::string;
  24. class pkgTagFilePrivate
  25. {
  26. public:
  27. pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Buffer(NULL),
  28. Start(NULL), End(NULL),
  29. Done(false), iOffset(0),
  30. Size(Size)
  31. {
  32. }
  33. FileFd &Fd;
  34. char *Buffer;
  35. char *Start;
  36. char *End;
  37. bool Done;
  38. unsigned long long iOffset;
  39. unsigned long long Size;
  40. };
  41. // TagFile::pkgTagFile - Constructor /*{{{*/
  42. // ---------------------------------------------------------------------
  43. /* */
  44. pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size)
  45. {
  46. /* The size is increased by 4 because if we start with the Size of the
  47. filename we need to try to read 1 char more to see an EOF faster, 1
  48. char the end-pointer can be on and maybe 2 newlines need to be added
  49. to the end of the file -> 4 extra chars */
  50. Size += 4;
  51. d = new pkgTagFilePrivate(pFd, Size);
  52. if (d->Fd.IsOpen() == false)
  53. d->Start = d->End = d->Buffer = 0;
  54. else
  55. d->Buffer = (char*)malloc(sizeof(char) * Size);
  56. if (d->Buffer == NULL)
  57. d->Done = true;
  58. else
  59. d->Done = false;
  60. d->Start = d->End = d->Buffer;
  61. d->iOffset = 0;
  62. if (d->Done == false)
  63. Fill();
  64. }
  65. /*}}}*/
  66. // TagFile::~pkgTagFile - Destructor /*{{{*/
  67. // ---------------------------------------------------------------------
  68. /* */
  69. pkgTagFile::~pkgTagFile()
  70. {
  71. free(d->Buffer);
  72. delete d;
  73. }
  74. /*}}}*/
  75. // TagFile::Offset - Return the current offset in the buffer /*{{{*/
  76. APT_PURE unsigned long pkgTagFile::Offset()
  77. {
  78. return d->iOffset;
  79. }
  80. /*}}}*/
  81. // TagFile::Resize - Resize the internal buffer /*{{{*/
  82. // ---------------------------------------------------------------------
  83. /* Resize the internal buffer (double it in size). Fail if a maximum size
  84. * size is reached.
  85. */
  86. bool pkgTagFile::Resize()
  87. {
  88. // fail is the buffer grows too big
  89. if(d->Size > 1024*1024+1)
  90. return false;
  91. return Resize(d->Size * 2);
  92. }
  93. bool pkgTagFile::Resize(unsigned long long const newSize)
  94. {
  95. unsigned long long const EndSize = d->End - d->Start;
  96. // get new buffer and use it
  97. char* newBuffer = (char*)realloc(d->Buffer, sizeof(char) * newSize);
  98. if (newBuffer == NULL)
  99. return false;
  100. d->Buffer = newBuffer;
  101. d->Size = newSize;
  102. // update the start/end pointers to the new buffer
  103. d->Start = d->Buffer;
  104. d->End = d->Start + EndSize;
  105. return true;
  106. }
  107. /*}}}*/
  108. // TagFile::Step - Advance to the next section /*{{{*/
  109. // ---------------------------------------------------------------------
  110. /* If the Section Scanner fails we refill the buffer and try again.
  111. * If that fails too, double the buffer size and try again until a
  112. * maximum buffer is reached.
  113. */
  114. bool pkgTagFile::Step(pkgTagSection &Tag)
  115. {
  116. while (Tag.Scan(d->Start,d->End - d->Start) == false)
  117. {
  118. if (Fill() == false)
  119. return false;
  120. if(Tag.Scan(d->Start,d->End - d->Start))
  121. break;
  122. if (Resize() == false)
  123. return _error->Error(_("Unable to parse package file %s (1)"),
  124. d->Fd.Name().c_str());
  125. }
  126. d->Start += Tag.size();
  127. d->iOffset += Tag.size();
  128. Tag.Trim();
  129. return true;
  130. }
  131. /*}}}*/
  132. // TagFile::Fill - Top up the buffer /*{{{*/
  133. // ---------------------------------------------------------------------
  134. /* This takes the bit at the end of the buffer and puts it at the start
  135. then fills the rest from the file */
  136. bool pkgTagFile::Fill()
  137. {
  138. unsigned long long EndSize = d->End - d->Start;
  139. unsigned long long Actual = 0;
  140. memmove(d->Buffer,d->Start,EndSize);
  141. d->Start = d->Buffer;
  142. d->End = d->Buffer + EndSize;
  143. if (d->Done == false)
  144. {
  145. // See if only a bit of the file is left
  146. unsigned long long const dataSize = d->Size - ((d->End - d->Buffer) + 1);
  147. if (d->Fd.Read(d->End, dataSize, &Actual) == false)
  148. return false;
  149. if (Actual != dataSize)
  150. d->Done = true;
  151. d->End += Actual;
  152. }
  153. if (d->Done == true)
  154. {
  155. if (EndSize <= 3 && Actual == 0)
  156. return false;
  157. if (d->Size - (d->End - d->Buffer) < 4)
  158. return true;
  159. // Append a double new line if one does not exist
  160. unsigned int LineCount = 0;
  161. for (const char *E = d->End - 1; E - d->End < 6 && (*E == '\n' || *E == '\r'); E--)
  162. if (*E == '\n')
  163. LineCount++;
  164. if (LineCount < 2)
  165. {
  166. if ((unsigned)(d->End - d->Buffer) >= d->Size)
  167. Resize(d->Size + 3);
  168. for (; LineCount < 2; LineCount++)
  169. *d->End++ = '\n';
  170. }
  171. return true;
  172. }
  173. return true;
  174. }
  175. /*}}}*/
  176. // TagFile::Jump - Jump to a pre-recorded location in the file /*{{{*/
  177. // ---------------------------------------------------------------------
  178. /* This jumps to a pre-recorded file location and reads the record
  179. that is there */
  180. bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset)
  181. {
  182. // We are within a buffer space of the next hit..
  183. if (Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset)
  184. {
  185. unsigned long long Dist = Offset - d->iOffset;
  186. d->Start += Dist;
  187. d->iOffset += Dist;
  188. // if we have seen the end, don't ask for more
  189. if (d->Done == true)
  190. return Tag.Scan(d->Start, d->End - d->Start);
  191. else
  192. return Step(Tag);
  193. }
  194. // Reposition and reload..
  195. d->iOffset = Offset;
  196. d->Done = false;
  197. if (d->Fd.Seek(Offset) == false)
  198. return false;
  199. d->End = d->Start = d->Buffer;
  200. if (Fill() == false)
  201. return false;
  202. if (Tag.Scan(d->Start, d->End - d->Start) == true)
  203. return true;
  204. // This appends a double new line (for the real eof handling)
  205. if (Fill() == false)
  206. return false;
  207. if (Tag.Scan(d->Start, d->End - d->Start) == false)
  208. return _error->Error(_("Unable to parse package file %s (2)"),d->Fd.Name().c_str());
  209. return true;
  210. }
  211. /*}}}*/
  212. // pkgTagSection::pkgTagSection - Constructor /*{{{*/
  213. // ---------------------------------------------------------------------
  214. /* */
  215. pkgTagSection::pkgTagSection()
  216. : Section(0), TagCount(0), d(NULL), Stop(0)
  217. {
  218. memset(&Indexes, 0, sizeof(Indexes));
  219. memset(&AlphaIndexes, 0, sizeof(AlphaIndexes));
  220. }
  221. /*}}}*/
  222. // TagSection::Scan - Scan for the end of the header information /*{{{*/
  223. // ---------------------------------------------------------------------
  224. /* This looks for the first double new line in the data stream.
  225. It also indexes the tags in the section. */
  226. bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
  227. {
  228. const char *End = Start + MaxLength;
  229. Stop = Section = Start;
  230. memset(AlphaIndexes,0,sizeof(AlphaIndexes));
  231. if (Stop == 0)
  232. return false;
  233. TagCount = 0;
  234. while (TagCount+1 < sizeof(Indexes)/sizeof(Indexes[0]) && Stop < End)
  235. {
  236. TrimRecord(true,End);
  237. // this can happen when TrimRecord trims away the entire Record
  238. // (e.g. because it just contains comments)
  239. if(Stop == End)
  240. return true;
  241. // Start a new index and add it to the hash
  242. if (isspace(Stop[0]) == 0)
  243. {
  244. Indexes[TagCount++] = Stop - Section;
  245. AlphaIndexes[AlphaHash(Stop,End)] = TagCount;
  246. }
  247. Stop = (const char *)memchr(Stop,'\n',End - Stop);
  248. if (Stop == 0)
  249. return false;
  250. for (; Stop+1 < End && Stop[1] == '\r'; Stop++)
  251. /* nothing */
  252. ;
  253. // Double newline marks the end of the record
  254. if (Stop+1 < End && Stop[1] == '\n')
  255. {
  256. Indexes[TagCount] = Stop - Section;
  257. TrimRecord(false,End);
  258. return true;
  259. }
  260. Stop++;
  261. }
  262. return false;
  263. }
  264. /*}}}*/
  265. // TagSection::TrimRecord - Trim off any garbage before/after a record /*{{{*/
  266. // ---------------------------------------------------------------------
  267. /* There should be exactly 2 newline at the end of the record, no more. */
  268. void pkgTagSection::TrimRecord(bool BeforeRecord, const char*& End)
  269. {
  270. if (BeforeRecord == true)
  271. return;
  272. for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++);
  273. }
  274. /*}}}*/
  275. // TagSection::Trim - Trim off any trailing garbage /*{{{*/
  276. // ---------------------------------------------------------------------
  277. /* There should be exactly 1 newline at the end of the buffer, no more. */
  278. void pkgTagSection::Trim()
  279. {
  280. for (; Stop > Section + 2 && (Stop[-2] == '\n' || Stop[-2] == '\r'); Stop--);
  281. }
  282. /*}}}*/
  283. // TagSection::Exists - return True if a tag exists /*{{{*/
  284. bool pkgTagSection::Exists(const char* const Tag)
  285. {
  286. unsigned int tmp;
  287. return Find(Tag, tmp);
  288. }
  289. /*}}}*/
  290. // TagSection::Find - Locate a tag /*{{{*/
  291. // ---------------------------------------------------------------------
  292. /* This searches the section for a tag that matches the given string. */
  293. bool pkgTagSection::Find(const char *Tag,unsigned int &Pos) const
  294. {
  295. unsigned int Length = strlen(Tag);
  296. unsigned int I = AlphaIndexes[AlphaHash(Tag)];
  297. if (I == 0)
  298. return false;
  299. I--;
  300. for (unsigned int Counter = 0; Counter != TagCount; Counter++,
  301. I = (I+1)%TagCount)
  302. {
  303. const char *St;
  304. St = Section + Indexes[I];
  305. if (strncasecmp(Tag,St,Length) != 0)
  306. continue;
  307. // Make sure the colon is in the right place
  308. const char *C = St + Length;
  309. for (; isspace(*C) != 0; C++);
  310. if (*C != ':')
  311. continue;
  312. Pos = I;
  313. return true;
  314. }
  315. Pos = 0;
  316. return false;
  317. }
  318. /*}}}*/
  319. // TagSection::Find - Locate a tag /*{{{*/
  320. // ---------------------------------------------------------------------
  321. /* This searches the section for a tag that matches the given string. */
  322. bool pkgTagSection::Find(const char *Tag,const char *&Start,
  323. const char *&End) const
  324. {
  325. unsigned int Length = strlen(Tag);
  326. unsigned int I = AlphaIndexes[AlphaHash(Tag)];
  327. if (I == 0)
  328. return false;
  329. I--;
  330. for (unsigned int Counter = 0; Counter != TagCount; Counter++,
  331. I = (I+1)%TagCount)
  332. {
  333. const char *St;
  334. St = Section + Indexes[I];
  335. if (strncasecmp(Tag,St,Length) != 0)
  336. continue;
  337. // Make sure the colon is in the right place
  338. const char *C = St + Length;
  339. for (; isspace(*C) != 0; C++);
  340. if (*C != ':')
  341. continue;
  342. // Strip off the gunk from the start end
  343. Start = C;
  344. End = Section + Indexes[I+1];
  345. if (Start >= End)
  346. return _error->Error("Internal parsing error");
  347. for (; (isspace(*Start) != 0 || *Start == ':') && Start < End; Start++);
  348. for (; isspace(End[-1]) != 0 && End > Start; End--);
  349. return true;
  350. }
  351. Start = End = 0;
  352. return false;
  353. }
  354. /*}}}*/
  355. // TagSection::FindS - Find a string /*{{{*/
  356. // ---------------------------------------------------------------------
  357. /* */
  358. string pkgTagSection::FindS(const char *Tag) const
  359. {
  360. const char *Start;
  361. const char *End;
  362. if (Find(Tag,Start,End) == false)
  363. return string();
  364. return string(Start,End);
  365. }
  366. /*}}}*/
  367. // TagSection::FindI - Find an integer /*{{{*/
  368. // ---------------------------------------------------------------------
  369. /* */
  370. signed int pkgTagSection::FindI(const char *Tag,signed long Default) const
  371. {
  372. const char *Start;
  373. const char *Stop;
  374. if (Find(Tag,Start,Stop) == false)
  375. return Default;
  376. // Copy it into a temp buffer so we can use strtol
  377. char S[300];
  378. if ((unsigned)(Stop - Start) >= sizeof(S))
  379. return Default;
  380. strncpy(S,Start,Stop-Start);
  381. S[Stop - Start] = 0;
  382. char *End;
  383. signed long Result = strtol(S,&End,10);
  384. if (S == End)
  385. return Default;
  386. return Result;
  387. }
  388. /*}}}*/
  389. // TagSection::FindULL - Find an unsigned long long integer /*{{{*/
  390. // ---------------------------------------------------------------------
  391. /* */
  392. unsigned long long pkgTagSection::FindULL(const char *Tag, unsigned long long const &Default) const
  393. {
  394. const char *Start;
  395. const char *Stop;
  396. if (Find(Tag,Start,Stop) == false)
  397. return Default;
  398. // Copy it into a temp buffer so we can use strtoull
  399. char S[100];
  400. if ((unsigned)(Stop - Start) >= sizeof(S))
  401. return Default;
  402. strncpy(S,Start,Stop-Start);
  403. S[Stop - Start] = 0;
  404. char *End;
  405. unsigned long long Result = strtoull(S,&End,10);
  406. if (S == End)
  407. return Default;
  408. return Result;
  409. }
  410. /*}}}*/
  411. // TagSection::FindFlag - Locate a yes/no type flag /*{{{*/
  412. // ---------------------------------------------------------------------
  413. /* The bits marked in Flag are masked on/off in Flags */
  414. bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
  415. unsigned long Flag) const
  416. {
  417. const char *Start;
  418. const char *Stop;
  419. if (Find(Tag,Start,Stop) == false)
  420. return true;
  421. return FindFlag(Flags, Flag, Start, Stop);
  422. }
  423. bool pkgTagSection::FindFlag(unsigned long &Flags, unsigned long Flag,
  424. char const* Start, char const* Stop)
  425. {
  426. switch (StringToBool(string(Start, Stop)))
  427. {
  428. case 0:
  429. Flags &= ~Flag;
  430. return true;
  431. case 1:
  432. Flags |= Flag;
  433. return true;
  434. default:
  435. _error->Warning("Unknown flag value: %s",string(Start,Stop).c_str());
  436. return true;
  437. }
  438. return true;
  439. }
  440. /*}}}*/
  441. // TFRewrite - Rewrite a control record /*{{{*/
  442. // ---------------------------------------------------------------------
  443. /* This writes the control record to stdout rewriting it as necessary. The
  444. override map item specificies the rewriting rules to follow. This also
  445. takes the time to sort the feild list. */
  446. /* The order of this list is taken from dpkg source lib/parse.c the fieldinfos
  447. array. */
  448. static const char *iTFRewritePackageOrder[] = {
  449. "Package",
  450. "Essential",
  451. "Status",
  452. "Priority",
  453. "Section",
  454. "Installed-Size",
  455. "Maintainer",
  456. "Original-Maintainer",
  457. "Architecture",
  458. "Source",
  459. "Version",
  460. "Revision", // Obsolete
  461. "Config-Version", // Obsolete
  462. "Replaces",
  463. "Provides",
  464. "Depends",
  465. "Pre-Depends",
  466. "Recommends",
  467. "Suggests",
  468. "Conflicts",
  469. "Breaks",
  470. "Conffiles",
  471. "Filename",
  472. "Size",
  473. "MD5sum",
  474. "SHA1",
  475. "SHA256",
  476. "SHA512",
  477. "MSDOS-Filename", // Obsolete
  478. "Description",
  479. 0};
  480. static const char *iTFRewriteSourceOrder[] = {"Package",
  481. "Source",
  482. "Binary",
  483. "Version",
  484. "Priority",
  485. "Section",
  486. "Maintainer",
  487. "Original-Maintainer",
  488. "Build-Depends",
  489. "Build-Depends-Indep",
  490. "Build-Conflicts",
  491. "Build-Conflicts-Indep",
  492. "Architecture",
  493. "Standards-Version",
  494. "Format",
  495. "Directory",
  496. "Files",
  497. 0};
  498. /* Two levels of initialization are used because gcc will set the symbol
  499. size of an array to the length of the array, causing dynamic relinking
  500. errors. Doing this makes the symbol size constant */
  501. const char **TFRewritePackageOrder = iTFRewritePackageOrder;
  502. const char **TFRewriteSourceOrder = iTFRewriteSourceOrder;
  503. bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
  504. TFRewriteData *Rewrite)
  505. {
  506. unsigned char Visited[256]; // Bit 1 is Order, Bit 2 is Rewrite
  507. for (unsigned I = 0; I != 256; I++)
  508. Visited[I] = 0;
  509. // Set new tag up as necessary.
  510. for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
  511. {
  512. if (Rewrite[J].NewTag == 0)
  513. Rewrite[J].NewTag = Rewrite[J].Tag;
  514. }
  515. // Write all all of the tags, in order.
  516. if (Order != NULL)
  517. {
  518. for (unsigned int I = 0; Order[I] != 0; I++)
  519. {
  520. bool Rewritten = false;
  521. // See if this is a field that needs to be rewritten
  522. for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
  523. {
  524. if (strcasecmp(Rewrite[J].Tag,Order[I]) == 0)
  525. {
  526. Visited[J] |= 2;
  527. if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
  528. {
  529. if (isspace(Rewrite[J].Rewrite[0]))
  530. fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  531. else
  532. fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  533. }
  534. Rewritten = true;
  535. break;
  536. }
  537. }
  538. // See if it is in the fragment
  539. unsigned Pos;
  540. if (Tags.Find(Order[I],Pos) == false)
  541. continue;
  542. Visited[Pos] |= 1;
  543. if (Rewritten == true)
  544. continue;
  545. /* Write out this element, taking a moment to rewrite the tag
  546. in case of changes of case. */
  547. const char *Start;
  548. const char *Stop;
  549. Tags.Get(Start,Stop,Pos);
  550. if (fputs(Order[I],Output) < 0)
  551. return _error->Errno("fputs","IO Error to output");
  552. Start += strlen(Order[I]);
  553. if (fwrite(Start,Stop - Start,1,Output) != 1)
  554. return _error->Errno("fwrite","IO Error to output");
  555. if (Stop[-1] != '\n')
  556. fprintf(Output,"\n");
  557. }
  558. }
  559. // Now write all the old tags that were missed.
  560. for (unsigned int I = 0; I != Tags.Count(); I++)
  561. {
  562. if ((Visited[I] & 1) == 1)
  563. continue;
  564. const char *Start;
  565. const char *Stop;
  566. Tags.Get(Start,Stop,I);
  567. const char *End = Start;
  568. for (; End < Stop && *End != ':'; End++);
  569. // See if this is a field that needs to be rewritten
  570. bool Rewritten = false;
  571. for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
  572. {
  573. if (stringcasecmp(Start,End,Rewrite[J].Tag) == 0)
  574. {
  575. Visited[J] |= 2;
  576. if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
  577. {
  578. if (isspace(Rewrite[J].Rewrite[0]))
  579. fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  580. else
  581. fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  582. }
  583. Rewritten = true;
  584. break;
  585. }
  586. }
  587. if (Rewritten == true)
  588. continue;
  589. // Write out this element
  590. if (fwrite(Start,Stop - Start,1,Output) != 1)
  591. return _error->Errno("fwrite","IO Error to output");
  592. if (Stop[-1] != '\n')
  593. fprintf(Output,"\n");
  594. }
  595. // Now write all the rewrites that were missed
  596. for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
  597. {
  598. if ((Visited[J] & 2) == 2)
  599. continue;
  600. if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
  601. {
  602. if (isspace(Rewrite[J].Rewrite[0]))
  603. fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  604. else
  605. fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
  606. }
  607. }
  608. return true;
  609. }
  610. /*}}}*/