~ubuntu-branches/ubuntu/hardy/wget/hardy-security

« back to all changes in this revision

Viewing changes to src/cmpt.c

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2005-06-26 16:46:25 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050626164625-jjcde8hyztx7xq7o
Tags: 1.10-2
* wget-fix_error--save-headers patch from upstream
  (closes: Bug#314728)
* don't pattern-match server redirects patch from upstream
  (closes: Bug#163243)
* correct de.po typos
  (closes: Bug#313883)
* wget-E_html_behind_file_counting fix problem with adding the
  numbers after the html extension
* updated Standards-Version: to 3.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Replacements for routines missing on some systems.
2
 
   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
 
2
   Copyright (C) 1995-2005 Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Wget.
5
5
 
121
121
#endif /* not HAVE_STRNCASECMP */
122
122
 
123
123
#ifndef HAVE_STRSTR
124
 
/* From GNU libc 2.0.6.  */
125
 
/* Return the first ocurrence of NEEDLE in HAYSTACK.  */
 
124
/* From GNU libc 2.3.5.  */
 
125
 
126
126
/*
127
127
 * My personal strstr() implementation that beats most other algorithms.
128
128
 * Until someone tells me otherwise, I assume that this is the
131
131
 * as much fun trying to understand it, as I had to write it :-).
132
132
 *
133
133
 * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
 
134
 
134
135
typedef unsigned chartype;
135
136
 
 
137
#undef strstr
 
138
 
136
139
char *
137
 
strstr (phaystack, pneedle)
138
 
     const char *phaystack;
139
 
     const char *pneedle;
 
140
strstr (const char *phaystack, const char *pneedle)
140
141
{
141
 
  register const unsigned char *haystack, *needle;
142
 
  register chartype b, c;
 
142
  const unsigned char *haystack, *needle;
 
143
  chartype b;
 
144
  const unsigned char *rneedle;
143
145
 
144
146
  haystack = (const unsigned char *) phaystack;
145
 
  needle = (const unsigned char *) pneedle;
146
147
 
147
 
  b = *needle;
148
 
  if (b != '\0')
 
148
  if ((b = *(needle = (const unsigned char *) pneedle)))
149
149
    {
150
 
      haystack--;                               /* possible ANSI violation */
151
 
      do
152
 
        {
153
 
          c = *++haystack;
154
 
          if (c == '\0')
 
150
      chartype c;
 
151
      haystack--;               /* possible ANSI violation */
 
152
 
 
153
      {
 
154
        chartype a;
 
155
        do
 
156
          if (!(a = *++haystack))
155
157
            goto ret0;
156
 
        }
157
 
      while (c != b);
 
158
        while (a != b);
 
159
      }
158
160
 
159
 
      c = *++needle;
160
 
      if (c == '\0')
 
161
      if (!(c = *++needle))
161
162
        goto foundneedle;
162
163
      ++needle;
163
164
      goto jin;
164
165
 
165
166
      for (;;)
166
 
        {
167
 
          register chartype a;
168
 
          register const unsigned char *rhaystack, *rneedle;
169
 
 
170
 
          do
171
 
            {
172
 
              a = *++haystack;
173
 
              if (a == '\0')
174
 
                goto ret0;
175
 
              if (a == b)
176
 
                break;
177
 
              a = *++haystack;
178
 
              if (a == '\0')
179
 
                goto ret0;
180
 
shloop:     }
181
 
          while (a != b);
182
 
 
183
 
jin:      a = *++haystack;
184
 
          if (a == '\0')
185
 
            goto ret0;
186
 
 
187
 
          if (a != c)
188
 
            goto shloop;
189
 
 
190
 
          rhaystack = haystack-- + 1;
191
 
          rneedle = needle;
192
 
          a = *rneedle;
193
 
 
194
 
          if (*rhaystack == a)
 
167
        {
 
168
          {
 
169
            chartype a;
 
170
            if (0)
 
171
            jin:{
 
172
                if ((a = *++haystack) == c)
 
173
                  goto crest;
 
174
              }
 
175
            else
 
176
              a = *++haystack;
195
177
            do
196
178
              {
197
 
                if (a == '\0')
198
 
                  goto foundneedle;
199
 
                ++rhaystack;
200
 
                a = *++needle;
201
 
                if (*rhaystack != a)
202
 
                  break;
203
 
                if (a == '\0')
204
 
                  goto foundneedle;
205
 
                ++rhaystack;
206
 
                a = *++needle;
 
179
                for (; a != b; a = *++haystack)
 
180
                  {
 
181
                    if (!a)
 
182
                      goto ret0;
 
183
                    if ((a = *++haystack) == b)
 
184
                      break;
 
185
                    if (!a)
 
186
                      goto ret0;
 
187
                  }
207
188
              }
208
 
            while (*rhaystack == a);
209
 
 
210
 
          needle = rneedle;             /* took the register-poor approach */
211
 
 
212
 
          if (a == '\0')
213
 
            break;
214
 
        }
 
189
            while ((a = *++haystack) != c);
 
190
          }
 
191
        crest:
 
192
          {
 
193
            chartype a;
 
194
            {
 
195
              const unsigned char *rhaystack;
 
196
              if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
 
197
                do
 
198
                  {
 
199
                    if (!a)
 
200
                      goto foundneedle;
 
201
                    if (*++rhaystack != (a = *++needle))
 
202
                      break;
 
203
                    if (!a)
 
204
                      goto foundneedle;
 
205
                  }
 
206
                while (*++rhaystack == (a = *++needle));
 
207
              needle = rneedle; /* took the register-poor aproach */
 
208
            }
 
209
            if (!a)
 
210
              break;
 
211
          }
 
212
        }
215
213
    }
216
214
foundneedle:
217
 
  return (char*) haystack;
 
215
  return (char *) haystack;
218
216
ret0:
219
217
  return 0;
220
218
}
792
790
     struct tm *tm;
793
791
     enum locale_status *decided;
794
792
{
 
793
#ifdef _NL_CURRENT
795
794
  const char *rp_backup;
 
795
#endif
796
796
  int cnt;
797
797
  size_t val;
798
798
  int have_I, is_pm;
832
832
    start_over:
833
833
#endif
834
834
 
 
835
#ifdef _NL_CURRENT
835
836
      /* Make back up of current processing pointer.  */
836
837
      rp_backup = rp;
 
838
#endif
837
839
 
838
840
      switch (*fmt++)
839
841
        {
1431
1433
  };
1432
1434
#endif
1433
1435
 
1434
 
#ifndef HAVE_USLEEP
1435
 
#ifndef WINDOWS
1436
 
 
1437
 
/* A simple usleep implementation based on select().  For Unix and
1438
 
   Unix-like systems.  */
1439
 
 
1440
 
int
1441
 
usleep (unsigned long usec)
1442
 
{
1443
 
  struct timeval tm;
1444
 
  tm.tv_sec = 0;
1445
 
  tm.tv_usec = usec;
1446
 
  select (0, NULL, NULL, NULL, &tm);
1447
 
  return 0;
1448
 
}
1449
 
 
1450
 
#endif /* not WINDOWS */
1451
 
#endif /* not HAVE_USLEEP */
1452
 
 
1453
 
 
1454
 
/* Currently unused in Wget.  Uncomment if we start using memmove
1455
 
   again. */
1456
 
#if 0
1457
 
 
1458
1436
#ifndef HAVE_MEMMOVE
1459
1437
void *
1460
1438
memmove (char *dest, const char *source, unsigned length)
1474
1452
}
1475
1453
#endif /* not HAVE_MEMMOVE */
1476
1454
 
1477
 
#endif /* 0 */
1478
 
 
1479
1455
/* fnmatch is a POSIX function, but we include an implementation for
1480
1456
   the sake of systems that don't have it.  Furthermore, according to
1481
1457
   anecdotal evidence, historical implementations of fnmatch are buggy