Import polish/fortunepl version 20091121
[dports.git] / archivers / ruby-lha / files / patch-math-remainder
1 Ruby 2.x #includes <math.h>, which declares a function named
2 remainder(). We must rename our variable to avoid name-conflict
3 and allow this code to compile with Ruby-2.x
4
5         -mi
6
7 --- ext/slide.c.orig    2006-09-17 17:45:51 UTC
8 +++ ext/slide.c
9 @@ -87,7 +87,7 @@ static struct decode_option decode_set;
10  
11  static unsigned int txtsiz;
12  static unsigned long dicsiz;
13 -static unsigned int remainder;
14 +static unsigned int iremainder;
15  
16  struct matchdata {
17      int len;
18 @@ -162,7 +162,7 @@ update_dict(pos, crc)
19  
20      n = fread_crc(crc, &text[txtsiz - dicsiz], dicsiz, infile);
21  
22 -    remainder += n;
23 +    iremainder += n;
24  
25      *pos -= dicsiz;
26      for (i = 0; i < HSHSIZ; i++) {
27 @@ -270,7 +270,7 @@ search_dict(token, pos, min, m)
28          /* re-search */
29          search_dict_1(token, pos, 0, off+2, m);
30  
31 -    if (m->len > remainder) m->len = remainder;
32 +    if (m->len > iremainder) m->len = iremainder;
33  }
34  
35  /* slide dictionary */
36 @@ -280,7 +280,7 @@ next_token(token, pos, crc)
37      unsigned int *pos;
38      unsigned int *crc;
39  {
40 -    remainder--;
41 +    iremainder--;
42      if (++*pos >= txtsiz - maxmatch) {
43          update_dict(pos, crc);
44  #ifdef DEBUG
45 @@ -316,17 +316,17 @@ encode(intf)
46      encode_set.encode_start();
47      memset(text, ' ', TXTSIZ);
48  
49 -    remainder = fread_crc(&crc, &text[dicsiz], txtsiz-dicsiz, infile);
50 +    iremainder = fread_crc(&crc, &text[dicsiz], txtsiz-dicsiz, infile);
51  
52      match.len = THRESHOLD - 1;
53      match.off = 0;
54 -    if (match.len > remainder) match.len = remainder;
55 +    if (match.len > iremainder) match.len = iremainder;
56  
57      pos = dicsiz;
58      token = INIT_HASH(pos);
59      insert_hash(token, pos);     /* associate token and pos */
60  
61 -    while (remainder > 0 && ! unpackable) {
62 +    while (iremainder > 0 && ! unpackable) {
63          last = match;
64  
65          next_token(&token, &pos, &crc);