~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to CONFIG/ARCHS/negfloat.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-04-13 10:07:52 UTC
  • Revision ID: james.westby@ubuntu.com-20020413100752-va9zm0rd4gpurdkq
Tags: upstream-3.2.1ln
ImportĀ upstreamĀ versionĀ 3.2.1ln

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <ctype.h>
 
3
#include <assert.h>
 
4
 
 
5
char *NegateFloats(char *ln)
 
6
{
 
7
   static char ol[512];
 
8
   char num[128];
 
9
   int i=0, j=0, k, h, ndot;
 
10
 
 
11
   do
 
12
   {
 
13
      if ( (ln[i] == '.') || isdigit(ln[i]) )
 
14
      {
 
15
         if (i==0 || isspace(ln[i-1]) || isdigit(ln[i]))
 
16
         {
 
17
            for (ndot=k=0; isdigit(ln[i]) || ln[i] == '.'; k++)
 
18
            {
 
19
               if (ln[i] == '.') ndot++;
 
20
               num[k] = ln[i++];
 
21
            }
 
22
            if (ndot == 1 && k > 1 && isspace(ln[i]))
 
23
            {
 
24
               if (j > 1 && ol[j-1] == ' ' && ol[j-2] == ' ') ol[j-1] = '-';
 
25
               else if (j == 0 || ol[j-1] != '-') ol[j++] = '-';
 
26
            }
 
27
            for (h=0; h < k; h++) ol[j++] = num[h];
 
28
         }
 
29
         else ol[j++] = ln[i++];
 
30
      }
 
31
      else ol[j++] = ln[i++];
 
32
   }
 
33
   while(ln[i]);
 
34
   ol[j] = '\0';
 
35
   return(ol);
 
36
}
 
37
 
 
38
main(int nargs, char **args)
 
39
{
 
40
   char tnam[256], ln[512], *lp;
 
41
   FILE *fpin, *fpout;
 
42
   int i;
 
43
 
 
44
   assert(tmpnam(tnam));
 
45
   for(i=1; i < nargs; i++)
 
46
   {
 
47
      fpin = fopen(args[i], "r");
 
48
      if (fpin == NULL)
 
49
      {
 
50
         fprintf(stderr, "FILE %s NOT FOUND, SKIPPING!!\n", args[i]);
 
51
         continue;
 
52
      }
 
53
      fpout = fopen(tnam, "w");
 
54
      assert(fpin);
 
55
      assert(fpout);
 
56
      while (fgets(ln, 512, fpin))
 
57
      {
 
58
         lp = NegateFloats(ln);
 
59
         fputs(lp, fpout);
 
60
      }
 
61
      fclose(fpin);
 
62
      fclose(fpout);
 
63
      remove(args[i]);
 
64
      sprintf(ln, "cp %s %s\n", tnam, args[i]);
 
65
      assert(system(ln) == 0);
 
66
      remove(tnam);
 
67
   }
 
68
   exit(0);
 
69
}