patch-index_build_in_c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. $OpenBSD: patch-index_build_in_c,v 1.1 2017/05/07 21:41:51 stu Exp $
  2. Index: index/build_in.c
  3. --- index/build_in.c.orig
  4. +++ index/build_in.c
  5. @@ -44,6 +44,13 @@ extern struct stat istbuf;
  6. extern struct stat excstbuf;
  7. extern struct stat incstbuf;
  8. +void build_hash();
  9. +void init_hash_table();
  10. +void insert_h();
  11. +void insert_index();
  12. +void merge_in(FILE *, FILE *, FILE *);
  13. +void remove_filename(int, int);
  14. +
  15. extern int ICurrentFileOffset;
  16. extern int NextICurrentFileOffset;
  17. @@ -121,6 +128,7 @@ extern struct indices *ip;
  18. extern int HashTableSize;
  19. struct token **hash_table; /*[MAX_64K_HASH];*/
  20. +void
  21. build_index()
  22. {
  23. int i;
  24. @@ -595,6 +603,7 @@ next_token:
  25. #endif
  26. }
  27. +void
  28. traverse1()
  29. {
  30. FILE *i1, *i2, *i3;
  31. @@ -777,6 +786,7 @@ build_hash():
  32. input: a set of filenames in name_list[], a partition table p_table[]
  33. output: a hash table hash_table[].
  34. -----------------------------------------------------------------------*/
  35. +void
  36. build_hash()
  37. {
  38. int fd; /* opened file number */
  39. @@ -1226,6 +1236,7 @@ try_again_1:
  40. my_free(buffer_begin, BLOCK_SIZE + 10);
  41. }
  42. +void
  43. init_hash_table()
  44. {
  45. int i;
  46. @@ -1245,6 +1256,7 @@ function: insert the word to appropriate position in t
  47. otherwise create a new token.
  48. THERE ARE NO STATE CHANGES UNLESS WE ARE SURE THAT MALLOCS WON'T FAIL: BG
  49. ---------------------------------------------------------------------------*/
  50. +void
  51. insert_h(word, pn, attribute)
  52. char *word;
  53. int pn;
  54. @@ -1282,7 +1294,8 @@ int attribute;
  55. traverse1();
  56. init_hash_table();
  57. tried_once = 1; /* memory allocation failed in malloc#1 */
  58. - return insert_h(word, pn, attribute); /* next call can't fail here since traverse() calls *allfree() */
  59. + insert_h(word, pn, attribute); /* next call can't fail here since traverse() calls *allfree() */
  60. + return;
  61. }
  62. if((tp->word = (char *) wordalloc(sizeof(char) * (wordlen+1))) == NULL) {
  63. @@ -1297,7 +1310,8 @@ int attribute;
  64. traverse1();
  65. init_hash_table();
  66. tried_once = 2; /* memory allocation failed in malloc#2 */
  67. - return insert_h(word, pn, attribute); /* next call can't fail here or above since traverse() calls *allfree() */
  68. + insert_h(word, pn, attribute); /* next call can't fail here or above since traverse() calls *allfree() */
  69. + return;
  70. }
  71. strcpy(tp->word, word);
  72. tp->attribute = attribute;
  73. @@ -1317,7 +1331,8 @@ int attribute;
  74. traverse1();
  75. init_hash_table();
  76. tried_once = 3; /* memory allocation failed in malloc#3 */
  77. - return insert_h(word, pn, attribute); /* next call can't fail here or above or above-above since traverse() calls *allfree() */
  78. + insert_h(word, pn, attribute); /* next call can't fail here or above or above-above since traverse() calls *allfree() */
  79. + return;
  80. }
  81. icount++;
  82. @@ -1363,6 +1378,7 @@ tp points to the token structure. so, tp->ip is always
  83. indices structure.
  84. THERE ARE NO STATE CHANGES UNLESS WE ARE SURE THAT MALLOCS WON'T FAIL: BG
  85. ------------------------------------------------------------------- */
  86. +void
  87. insert_index(tp, pn)
  88. struct token *tp; /* insert a index into a indices structure */
  89. int pn;
  90. @@ -1411,7 +1427,8 @@ int pn;
  91. traverse1();
  92. init_hash_table();
  93. tried_once = 1; /* memory allocation failed in malloc#1 */
  94. - return insert_index(tp, pn);
  95. + insert_index(tp, pn);
  96. + return;
  97. }
  98. icount++;
  99. @@ -1471,6 +1488,7 @@ extern unsigned char *dest_index_buf;
  100. extern unsigned char *merge_index_buf;
  101. /* merge index file f1 and f2, then put the result in index file f3 */
  102. +void
  103. merge_in(f1, f2, f3)
  104. FILE *f1, *f2, *f3;
  105. {
  106. @@ -1849,6 +1867,7 @@ printf("in merge_in()\n"); fflush(stdout);
  107. return;
  108. }
  109. +void
  110. remove_filename(fileindex, new_partition)
  111. int fileindex, new_partition;
  112. {