241145← ↑修正パッチ →241147


2004.07.18 (日) 15:00:58 <u*j*2*6*> ついでにKeywords.pasの383行目でATimeの型をCardinalに変えてあります(警告をさけるため)
2004.07.18 (日) 15:02:28 <u*j*2*6*> あとはshuusei241136と同じようにコメントの折り返されてないとこと、無意味に語頭が大文字になってるとこをなおしました。

shuusei241146:Keywords.pas, Keywords2.pasの整形(241121参照)

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
-
!
 
 
 
 
 
 
 
-
|
|
|
|
-
|
|
|
!
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
-
|
|
-
|
-
|
|
|
|
|
-
|
|
!
!
|
-
|
-
|
|
-
|
|
|
|
|
-
|
-
|
|
|
|
|
|
-
|
|
-
|
-
|
|
|
|
|
-
|
|
|
!
!
|
-
-
|
|
|
|
|
-
|
|
-
|
|
-
|
-
|
|
|
|
|
-
|
|
!
!
|
-
|
-
|
|
-
|
|
!
|
|
|
|
-
|
|
|
|
|
|
|
!
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
|
-
!
|
|
|
|
|
|
|
|
|
|
-
!
|
-
|
|
-
-
|
|
|
|
|
-
|
|
|
|
|
|
|
-
-
|
|
-
!
|
-
|
-
|
-
|
|
|
|
|
-
|
|
|
|
|
|
!
|
|
|
|
-
-
|
|
|
|
!
|
!
|
|
|
|
|
|
!
|
-
!
|
|
|
-
-
|
|
|
|
!
|
|
-
-
|
|
-
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
|
-
!
|
|
|
|
|
|
|
|
-
|
|
|
|
!
|
|
|
-
|
|
|
|
|
|
|
|
|
!
!
!
|
!
|
|
|
!
|
!
diff --dos -urN 241145/keywords.pas 241146/keywords.pas
--- 241145/keywords.pas    Wed Apr 28 00:00:00 2004
+++ 241146/keywords.pas    Sun Jul 18 14:47:36 2004
@@ -25,8 +25,8 @@
 
 {$I Defines.pas}
 
-procedure InitKeywords; // Should be Called before First share/Search command
-procedure FreeKeywords; // Should be Called after All files Are unshared
+procedure InitKeywords; // Should be called before first share/search command
+procedure FreeKeywords; // Should be called after all files are unshared
 function SplitToKeywords(Str: string; List: TNapCmdList;
   Limit: Integer): Integer;
 procedure SplitToKeywordsEx(Inc_Str, Exc_Str: string;
@@ -38,10 +38,10 @@
 
 var
   // Global list of keywords.
-  // Sorted this Way (3-Dimentional array to search it faster):
-  // 1 - type of Shared file: SHARED_Xxx Constants
+  // Sorted this way (3-dimentional array to search it faster):
+  // 1 - Type of shared file: SHARED_XXX constants
   // 2 - First character of keyword
-  // 3 - Length of Keyword
+  // 3 - Length of keyword
   DB_Keywords: array[0..SHARED_ARRAY - 1, 0..KEYWORDS_FIRST_COUNT - 1,
     KEYWORD_LEN_MIN..KEYWORD_LEN_MAX] of PKeywordList;
 
@@ -77,15 +77,15 @@
     end
     else if (T = mbSingleByte) and (Tprev = mbTrailByte) then
     begin
-      if (Str^[I] = '゙') and (Str^[I - 2] = #$82) and (StrScan(HIRAGANA_D, Str^[I
-        - 1]) <> nil) then
+      if (Str^[I] = '゙') and (Str^[I - 2] = #$82) and
+        (StrScan(HIRAGANA_D, Str^[I - 1]) <> nil) then
       begin // 濁音になれる全角ひらがな+'゙'を濁音に変換
         Inc(Str^[I - 1]);
         Delete(Str^, I, 1);
         Dec(I);
       end
-      else if (Str^[I] = '゚') and (Str^[I - 2] = #$82) and (StrScan(HIRAGANA_H,
-        Str^[I - 1]) <> nil) then
+      else if (Str^[I] = '゚') and (Str^[I - 2] = #$82) and
+        (StrScan(HIRAGANA_H, Str^[I - 1]) <> nil) then
       begin // 半濁音になれる全角ひらがな+'゚'を半濁音に変換
         Inc(Str^[I - 1], 2);
         Delete(Str^, I, 1);
@@ -184,7 +184,8 @@
   C: Char;
   Item: string;
 begin // Extract up to $limit keywords from string and add it to list with CRC
-  // Before calling this function you should add ' ' at the end of string or you might loose your last keyword
+  // Before calling this function you should add ' ' at the end of string
+    // or you might loose your last keyword
   Tmp_Pos := 12262;
   Split2ByteString(@Str);
   Tmp_Pos := 1280;
@@ -196,18 +197,19 @@
   begin
     C := Str[I];
     if Spacing then
-    begin // Searching for Beginning of Keyword
-      //     if Pos(C, KEYWORDS_FIRST) > 0 then // Found our First keyword Character
+    begin // Searching for beginning of keyword
+      // if Pos(C, KEYWORDS_FIRST) > 0 then
+        // Found our first keyword character
       if Pos(C, KEYWORDS_SEPARATORS) = 0 then
-        // Found our First keyword Character
+        // Found our first keyword character
       begin
         Start := I;
         Spacing := False;
       end;
     end
     else
-    begin // Searching for end of Keyword
-      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found Spacing
+    begin // Searching for end of keyword
+      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found spacing
         if ByteType(Str, I) = mbSingleByte then
         begin
           Spacing := True;
@@ -238,8 +240,9 @@
   Spacing, HardSpacing, Excluding, Last_Exc: Boolean;
   C: Char;
   Item: string;
-begin // Extract up to $Limit keywords From string and add It to List with CRC
-  // Before calling This function You should Add ' ' At the end of string or You might Loose your Last keyword
+begin // Extract up to $limit keywords from string and add it to list with CRC
+  // Before calling this function you should add ' ' at the end of string
+    // or you might loose your last keyword
   Tmp_Pos := 12262;
   Split2byteString(@Inc_Str);
   Split2byteString(@Exc_Str);
@@ -253,10 +256,11 @@
   begin
     C := Inc_Str[I];
     if Spacing then
-    begin // Searching for Beginning of Keyword
-      //     if Pos(C, KEYWORDS_FIRST) > 0 then // Found our First keyword Character
+    begin // Searching for beginning of keyword
+      // if Pos(C, KEYWORDS_FIRST) > 0 then
+        // Found our first keyword character
       if Pos(C, KEYWORDS_SEPARATORS) = 0 then
-        // Found our First keyword Character
+        // Found our first keyword character
       begin
         Start := I;
         Spacing := False;
@@ -278,10 +282,10 @@
       end;
     end
     else
-    begin // Searching for end of Keyword
+    begin // Searching for end of keyword
       Last_Exc := False;
       HardSpacing := False;
-      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found Spacing
+      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found spacing
         if ByteType(Inc_Str, I) = mbSingleByte then
         begin
           Spacing := True;
@@ -323,18 +327,19 @@
   begin
     C := Exc_Str[I];
     if Spacing then
-    begin // Searching for Beginning of Keyword
-      //     if Pos(C, KEYWORDS_FIRST) > 0 then // Found our First keyword Character
+    begin // Searching for beginning of keyword
+      // if Pos(C, KEYWORDS_FIRST) > 0 then
+        // Found our first keyword character
       if Pos(C, KEYWORDS_SEPARATORS) = 0 then
-        // Found our First keyword Character
+        // Found our first keyword character
       begin
         Start := I;
         Spacing := False;
       end;
     end
     else
-    begin // Searching for end of Keyword
-      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found Spacing
+    begin // Searching for end of keyword
+      if Pos(C, KEYWORDS_SEPARATORS) > 0 then // Found spacing
         if ByteType(Exc_Str, I) = mbSingleByte then
         begin
           Spacing := True;
@@ -360,12 +365,12 @@
 end;
 
 function GetKeywordIndex(Keyword: string): Integer;
-// Returns index of keyword or -1 if keyword Is invalid
+// Returns index of keyword or -1 if keyword is invalid
 begin
   if Length(Keyword) < 1 then
     Result := KEYWORDS_NOINDEX
   else if Pos(Keyword[1], KEYWORDS_FIRST) = 0 then
-    Result := KEYWORDS_FIRST_COUNT - 1 // 2byte Char
+    Result := KEYWORDS_FIRST_COUNT - 1 // 2byte char
   else
     Result := Pos(Keyword[1], KEYWORDS_FIRST) - 1;
 end;
@@ -383,7 +388,7 @@
 procedure FreeKeywords;
 var
   I, J, K: Integer;
-  ATime: Integer;
+  ATime: Cardinal;
 begin
   ATime := GetTickCount;
   for I := 0 to SHARED_ARRAY - 1 do
diff --dos -urN 241145/keywords2.pas 241146/keywords2.pas
--- 241145/keywords2.pas    Wed Apr 28 00:00:00 2004
+++ 241146/keywords2.pas    Sun Jul 18 14:46:30 2004
@@ -25,15 +25,17 @@
 {$I Defines.pas}
 
 const
-  ITEMS_PER_KEYWORD = 29; // *4 + 12 = 256 Bytes
+  ITEMS_PER_KEYWORD = 29; // *4 + 12 = 256 bytes
   KEYWORD_MOVE_ITEMS = 10;
-    // if number of Items in TKeywordItem Is less Than this All Items Are moved to another Incomplete TKeywordItem - to make Lower memory Usage.
+    // If number of items in TKeywordItem is less than this
+      // all items are moved to another incomplete TKeywordItem
+      // - to make lower memory usage.
 
 type
   PKeywordItem = ^TKeywordItem;
   TKeywordItem = Packed record // One item in TKeyword
     Share: array[0..ITEMS_PER_KEYWORD - 1] of PShare;
-    Used: Integer; // Number of Used Items
+    Used: Integer; // Number of used items
     Prev, Next: PKeywordItem;
   end;
   PKeyword = ^TKeyword;
@@ -43,10 +45,10 @@
       // Number of files matching keyword (Might not be all in this list)
     Available: Integer; // Number of available slots in incomplete list
     Keyword: string; // Keyword
-    KwLength: Byte; // Keyword length. for faster Comparison
-    Id: Byte; // File ID. for faster detection of List
-    Complete: PKeywordItem; // Pointer to first full Item
-    Incomplete: PKeywordItem; // Pointer to first incomplete Item
+    KwLength: Byte; // Keyword length. For faster comparison
+    Id: Byte; // File ID. For faster detection of list
+    Complete: PKeywordItem; // Pointer to first full item
+    Incomplete: PKeywordItem; // Pointer to first incomplete item
     Prev, Next: PKeyword;
       // Pointer to previous and next PKeyword items in global list
   end;
@@ -200,7 +202,7 @@
 begin
   Tmp_Pos := 1296;
   if not Running then
-  begin // if server Is shutting Down - Quickly freing Variables
+  begin // If server is shutting down - quickly freing variables
     Keyword^.Count := 0;
     Keyword^.Complete := nil;
     Keyword^.Incomplete := nil;
@@ -237,9 +239,12 @@
   I: Integer;
 begin
   Tmp_Pos := 1300;
-  // DebugLog(' Adding PShare to (' + IntToStr(Keyword^.Id) + ') ' + Keyword^.Keyword + ' Count=' + IntToStr(Keyword^.Count) + ' Total=' + IntToStr(Keyword^.Total) + ' Available=' + IntToStr(Keyword^.Available), True);
+  // DebugLog(' Adding PShare to (' + IntToStr(Keyword^.Id) + ') ' +
+    // Keyword^.Keyword + ' Count=' + IntToStr(Keyword^.Count) +
+    // ' Total=' + IntToStr(Keyword^.Total) + ' Available=' +
+    // IntToStr(Keyword^.Available), True);
   if (Keyword^.Count >= MAX_KEYWORD_ITEMS) and (Keyword^.Available = 0) then
-  begin // Adding only Reference
+  begin // Adding only reference
     Inc(Keyword^.Total);
     Result := nil;
     // DebugLog(' Added only Reference', True);
@@ -247,14 +252,15 @@
   else
   begin
     if Keyword^.Available > 0 then
-    begin // Adding to Current item
-      // DebugLog(' Adding to Existing record. Available=' + IntToStr(Keyword^.Available), True);
+    begin // Adding to current item
+      // DebugLog(' Adding to Existing record. Available=' +
+        // IntToStr(Keyword^.Available), True);
       Tmp_Pos := 1301;
       Result := Keyword^.Incomplete;
       if Result = nil then
       begin
-        DebugLog('Warning: KWList_AddShare(): Result->Incomplete==NULL while Keyword->Availabe='
-          + IntToStr(Keyword^.Available) +
+        DebugLog('Warning: KWList_AddShare(): Result->Incomplete==NULL' +
+          ' while Keyword->Availabe=' + IntToStr(Keyword^.Available) +
           '. Please Report this Error to Developers!!!');
         Exit;
       end;
@@ -268,7 +274,7 @@
           Inc(Keyword^.Total);
           Inc(Keyword^.Count);
           if Result^.Used = ITEMS_PER_KEYWORD then
-          begin // All slots in Result Are taken - Move to Complete list
+          begin // All slots in result are taken - move to complete list
             Tmp_Pos := 1303;
             Keyword^.Incomplete := Result^.Next;
             if Result^.Next <> nil then
@@ -280,9 +286,10 @@
           end;
           Exit;
         end;
-      // if program got here then some weird error occured when .available <> 0
+      // If program got here then some weird error occured when .available <> 0
       Tmp_Pos := 1304;
-      DebugLog('Warning: KWList_AddShare(): Cannot find empty item. Please report this error to developers!!!');
+      DebugLog('Warning: KWList_AddShare(): Cannot find empty item. ' +
+        'Please report this error to developers!!!');
     end;
     Tmp_Pos := 1305;
     // DebugLog(' Creating new record', True);
@@ -331,7 +338,7 @@
       Dec(Keyword^.Count);
       Inc(Keyword^.Available);
       if OldCount = ITEMS_PER_KEYWORD then
-      begin // Move from Complete list to incomplete List
+      begin // Move from complete list to incomplete list
         Tmp_Pos := 1310;
         if Item^.Prev <> nil then
           Item^.Prev^.Next := Item^.Next
@@ -364,11 +371,11 @@
       end;
       if (Item^.Used <= KEYWORD_MOVE_ITEMS) and
         (Keyword^.Available > ITEMS_PER_KEYWORD) then
-      begin // Moving to Another Items
+      begin // Moving to another items
         for L := 0 to ITEMS_PER_KEYWORD - 1 do
           if Item^.Share[L] <> nil then
           begin
-            // Finding other Free item
+            // Finding other free item
             P := Keyword^.Incomplete;
             Found := False;
             while not Found do
@@ -380,13 +387,15 @@
               else
                 Found := True;
             end;
-            if P = nil then Exit; // Some kind of error - Cannot find Empty item
+            if P = nil then Exit;
+              // Some kind of error - cannot find empty item
             Pos := -1;
             for J := 0 to ITEMS_PER_KEYWORD - 1 do
               if Pos = -1 then
                 if P^.Share[J] = nil then
                   Pos := J;
-            if Pos = -1 then Exit; // Some kind of weird Error - Cannot find Empty slot
+            if Pos = -1 then Exit;
+              // Some kind of weird error - cannot find empty slot
             // Moving item
             P^.Share[Pos] := Item^.Share[L];
             Inc(P^.Used);
@@ -398,7 +407,7 @@
             for K := 0 to Words - 1 do
               if Share^.Keywords^[K * 2 + 1] = Item then
                 Share^.Keywords^[K * 2 + 1] := P;
-            // if P Is full Moving to Complete list
+            // If P is full moving to complete list
             if P^.Used = ITEMS_PER_KEYWORD then
             begin
               if P^.Prev = nil then
@@ -413,7 +422,7 @@
               Keyword^.Complete := P;
               P^.Prev := nil;
             end;
-            // if item Is empty Freing it
+            // If item is empty freing it
             if Item^.Used = 0 then
             begin
               Dec(Keyword^.Available, ITEMS_PER_KEYWORD);
@@ -426,14 +435,16 @@
               FreeMem(Item, SizeOf(TKeywordItem));
               if (Keyword^.Count = 0) and (Keyword^.Total = 0) then
                 KWList_DeleteItem(DB_Keywords[Keyword^.Id,
-                  GetKeywordIndex(Keyword^.Keyword), Keyword^.KwLength], Keyword);
+                  GetKeywordIndex(Keyword^.Keyword),
+                  Keyword^.KwLength], Keyword);
               Exit;
             end;
           end;
       end;
       Exit;
     end;
-  DebugLog('Warning: KWList_DeleteShare(): Cannot find Item. Please Report this Error to Developers!!!');
+  DebugLog('Warning: KWList_DeleteShare(): Cannot find Item. ' +
+    'Please Report this Error to Developers!!!');
 end;
 
 end.
241145← ↑修正パッチ →241147