Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
 x86_64-w64-mingw32-gcc-6.4.0.exe  -Wall -pedantic -ansi txt2htm.c  -o num2htm.exe
txt2htm.c: Dans la fonction «*getlines*»:
txt2htm.c:116:16: warning: la comparaison de la constante «*122*» avec une expression booléenne est toujours vraie [-Wbool-compare]
     if (32 < c <= 'z') {
                ^~
txt2htm.c:116:12: warning: les comparaisons telles que «*X<=Y<=Z*» n'ont pas leur signification mathématique [-Wparentheses]
     if (32 < c <= 'z') {
         ~~~^~~
txt2htm.c:155:16: warning: la comparaison de la constante «*122*» avec une expression booléenne est toujours vraie [-Wbool-compare]
     if (32 < c <= 'z' && tabulations > 0) {
                ^~
txt2htm.c:155:12: warning: les comparaisons telles que «*X<=Y<=Z*» n'ont pas leur signification mathématique [-Wparentheses]
     if (32 < c <= 'z' && tabulations > 0) {
         ~~~^~~
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
char getlines(char s[]) {
  int c;
  int i = 0;
  char d[1024];
..............
  int tabulations = 0;
  int tabon = 0;
 
.............
 
 
  while ((c = getchar()) != EOF) {
...................
    if (32 < c <= 'z') {
 
      if (tabulations > 0) {
        printf("<img src=\"pixel.png\" width=%d height=0 border=0 alt=\"|\">", tabulations);
        tabulations = 0;
        tabon = 0;
      }
 
      s[i] = c;
      ++i;
      break;
    }
..............................

Qu'est-ce qu"il veut dire?
Un caractère n'est pa toujours (32 < c <= 'z').


JPD



=================
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
/*
* to preprocess using CYGWIN tools:
*   cpp -E -P -C -o rgb2html.java rgb2html_in.java
*
* or, using BORLAND BCC55 tools:
*   cpp32 -Sr -Sc -otextToHtml.java rgb2html_in.java
 
* cpp32 -Sr -Sc -otextToHtml.c txToHt.c
 
* https://www.developpez.net/forums/d1865869/c-cpp/cpp/mingw-64-ne-compile/#post10315347
* x86_64-w64-mingw32-gcc-6.4.0.exe  -Wall -pedantic -ansi txt2htm.c  -o num2htm.exe
*
* ./num2htm.exe  titre 0 <asm.c>asm.c.htm
*/
#include <stdio.h>
 
#include <string.h>
 
 
#define MAXLINE 2500
#define HEADER "<head>"     /* #ece2bc   fdf5e6 */
#define  STYLE  "<style>\nbody{background-color:#d9d5cd; font-size:28px; color:#29043c;}\nem {color:#aaa;}\n</style>"
#define  FOOTER "</body>"
 
char getlines(char s[]);
char lignevide(char to[], char from[]);
void makealine(char sin[], int j);
void usage(void);
int un_P = 0;
int num =0;
 
int main(int argc, char *argv[]) {
 
  char line[MAXLINE];
  char *thetitle = argv[1];
	char donumber = *argv[2];
 
  if (argc < 3 ) {
    usage();
    return 0;
  }
 
  printf(HEADER"\n");
  printf("\n"STYLE);
  printf( "\n</head>\n");
 
  printf("<body>\n<center><h2>%s</h2></center>\n", thetitle);
 
  while (getlines(line) != 0)
	{
		num++;
		if (donumber == '0')
		{
			printf("%s", line);
			}else
			(num < 10) ? printf("<em>%d</em>&nbsp;&nbsp;&nbsp;&nbsp;%s", num, line) : printf("<em>%d</em>&nbsp;&nbsp;%s", num, line);
  }
 
  printf("</p>");
  printf("\n"FOOTER"\n");
 
  return 0;
}
 
char getlines(char s[]) {
  int c;
  int i = 0;
  char d[1024];
  int split = 0;
  int tabulations = 0;
  int tabon = 0;
  int dash = 0;
 
  if (un_P == 0) {
    printf("\n<p>");
    un_P = 1;
  }
 
  while ((c = getchar()) != EOF) {
 
 
		if ( dash == 0 && c == '#') {
			s[i] = c;
      ++i;
      dash = 1;
      continue;
    }
 
    if (c == '\t') {
      tabon = 1;
      tabulations = tabulations + 2;
      continue;
    }
 
    if (c == ' ' && tabon == 1) {
      tabulations += 1;
      continue;
    }
 
    if (c == '\n') {
      s[i] = '<';
      ++i;
      s[i] = '/';
      ++i;
      s[i] = 'p';
      ++i;
      s[i] = '>';
      ++i;
      s[i] = '\n';
      ++i;
      s[i] = '\0';
      un_P = 0;
      return lignevide(d, s);
    }
 
    if (32 < c <= 'z') {
 
      if (tabulations > 0) {
        printf("<img src=\"pixel.png\" width=%d height=0 border=0 alt=\"|\">", tabulations);
        tabulations = 0;
        tabon = 0;
      }
 
      s[i] = c;
      ++i;
      break;
    }
 
    s[i] = c;
    ++i;
  }/* end first while */
 
  while ((c = getchar()) != EOF &&  c != '\n') {
 
 
		if (dash == 1 && c == '<') {
      s[i] = c;
      ++i;
      s[i] = '.';
      ++i;
			dash = 0;
      continue;
    }
 
    if (c == '\t') {  /* \t = 2 */
      tabon = 1;
      tabulations = tabulations + 2;
      continue;
    }
    if (c == ' ' && tabon == 1) {
      tabulations = tabulations + 2;
      continue;
    }
 
    if (32 < c <= 'z' && tabulations > 0) {
      printf("<img src=\"pixel.png\" width=%d height=0 border=0 alt=\"|\">", tabulations);
      tabulations = 0;
      tabon = 0;
    }
 
    s[i++] = c;
 
    		if (i%80 == 0 && split == 0)
    		{
    		   while((c = getchar()) != ' ' &&  c != '\n' && c != EOF)
    								s[i++] = c;
 
    		   if(un_P == 1){
    		   s[i++] = '<';
     		   s[i++] = 'b';
    		   s[i++] = 'r';
    		   s[i++] = '>';
    		   split = 1;
    		   }
    		}
 
  }
 
  if (c == '\n') {
    if (un_P == 1) {
      s[i] = '<';
      ++i;
      s[i] = '/';
      ++i;
      s[i] = 'b';
      ++i;
      s[i] = 'r';
      ++i;
      s[i] = '>';
      ++i;
      s[i] = '\n';
      ++i;
    }
    s[i] = c;
  }
  s[i] = '\0';
 
  return *s;
}
 
char lignevide(char to[], char from[]) {
  int i;
 
  for (i = 0; from[i] != '\0' ; i++) {
    if (to[i] != ' ' && to[i] != '\t')
      to[i] = from[i];
  }
 
	to[i+1] = '\0';
 
  return *to;
}
 
void usage() {
  printf("\nUsage: xtTohtm [ title ] [donumber: true > 0] [ < input file.txt ]  [ > output file.html ]\n");
}