summary refs log tree commit diff stats
path: root/compiler/plugins
Commit message (Collapse)AuthorAgeFilesLines
* IC: next steps (#16550)Andreas Rumpf2021-01-071-2/+2
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-022-3/+3
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* refactorings to prepare the compiler for IC (#15935)Andreas Rumpf2020-12-171-2/+1
| | | | | | | | | | | | | | * added ic specific Nim code; WIP * make the symbol import mechanism lazy; WIP * ensure that modules can be imported multiple times * ambiguity checking * handle converters and TR macros properly * make 'enum' test category green again * special logic for semi-pure enums * makes nimsuggest tests green again * fixes nimdata * makes nimpy green again * makes more important packages work
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-252-5/+5
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-282-2/+2
| | | | | | | | | | | | | | | | | | * Cleanup compiler code base * Unify add calls * Unify len invocations * Unify range operators * Fix oversight * Remove {.procvar.} pragma * initCandidate -> newCandidate where reasonable * Unify safeLen calls
* fixes #11958 (#12013)Andreas Rumpf2019-08-231-12/+11
|
* [refactoring] remove unused imports in the compiler and in some stdlib modulesAraq2019-07-182-4/+2
|
* rename tyExpr/tyStmt to tyUntyped/tyTyped (#11227)Arne Döring2019-05-111-1/+1
|
* Fix locals() interaction with generic typesLemonBoy2018-09-211-1/+1
| | | | | | | Follow the same logic as semTupleFieldsConstr and only skip skVar since we're gonna add a nkDefer anyway. Fixes #8985
* cleanup import pathsAraq2018-09-211-1/+1
|
* baby steps for incremental compilationAndreas Rumpf2018-05-301-1/+1
|
* active.nim: fixes the import path so that compilation with --noNimblePath worksAndreas Rumpf2018-05-291-1/+1
|
* refactoring: fewer global variablesAndreas Rumpf2018-05-273-9/+16
|
* remove ast.emptyNode global; cleanup configuration.nimAraq2018-05-161-4/+4
|
* more modules compile againAndreas Rumpf2018-05-121-5/+5
|
* warn about inconsistent spacing around binary operators; fixes #7582Andreas Rumpf2018-05-051-1/+1
|
* fixes #7522Araq2018-04-063-7/+6
|
* big compiler refactoring; avoid globals for multi method dispatcher generationAndreas Rumpf2017-02-221-1/+1
|
* fixes #3622Andreas Rumpf2015-12-042-4/+6
|
* lambda lifting support for iterToProc pluginAraq2015-12-011-0/+49
|
* added iterToProc pluginAraq2015-12-011-1/+1
|
* Hopefully fixes nimsuggest building against the compiler package.Dominik Picheta2015-06-041-1/+2
|
* system.locals is now a plugin for educationAraq2015-04-242-0/+55
ynx-snapshots/blame/src/LYExtern.c?id=83824f14360f92f8a3a47ac5f136bb077b141065'>^
2b52e9e6 ^

a2a1ab1e ^



2b52e9e6 ^
a2a1ab1e ^






2b52e9e6 ^
a2a1ab1e ^








95586cc2 ^
a2a1ab1e ^



a2a1ab1e ^

2b52e9e6 ^
a2a1ab1e ^







2b52e9e6 ^
a2a1ab1e ^


ab1d1ae5 ^
2b52e9e6 ^
a2a1ab1e ^

2b52e9e6 ^
a2a1ab1e ^


a2a1ab1e ^
2b52e9e6 ^


a2a1ab1e ^






2b52e9e6 ^

a2a1ab1e ^
























2b52e9e6 ^
a2a1ab1e ^

2b52e9e6 ^
a2a1ab1e ^

2b52e9e6 ^
a2a1ab1e ^


ab1d1ae5 ^

2b52e9e6 ^
ab1d1ae5 ^

a2a1ab1e ^


2b52e9e6 ^
a2a1ab1e ^



95586cc2 ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^

a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^

a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^







2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^








2b52e9e6 ^
a2a1ab1e ^





2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^
2b52e9e6 ^
a2a1ab1e ^


2b52e9e6 ^

a2a1ab1e ^




2b52e9e6 ^
a2a1ab1e ^


2b52e9e6 ^
a2a1ab1e ^















2b52e9e6 ^
a2a1ab1e ^


2b52e9e6 ^
a2a1ab1e ^


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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
















                                                                        
                    


                    

                         
                     
                    
                     
 





































                                                                      
                                                                        










































































                                                                               
 

                                 
 
                                                         
 

                                                              
 


                                                       
 

                                                               
 
                                       
 




                                      
 
                  
         
     
 
           
 






                                  

                  



                                  
                        






                                                               
                                                 








                                                    
                                                                         



                                                                          

                                                              
                      







                                                                              
                                                        


                                                       
                                             
                                                             

                         
                                                                 


                                           
                                                     


                                                                    






                                                              

                                                                       
























                                                                         
                                           

                                                                               
                                                                         

                        
                                                                


                  

                                               
                                                             

                         


                 
                                                 



                                                               
                                                               
                                                               
                                                      
                                                                 

                                                                        
     
                                                                      
      

                              
 
                                     







                                                                                 
                                                      
      
                          
                        
                                            
                 
 
                                                       








                                        
                                  





                                                               
                                        
     
                                         
      
                                  


                                                             

                                                                    




                                                                       
                                                      


                        
                                 















                                                  
                  


                      
                 


                           
/*
 External application support.
 This feature allows lynx to pass a given URL to an external program.
 It was written for three reasons.
 1) To overcome the deficiency	of Lynx_386 not supporting ftp and news.
    External programs can be used instead by passing the URL.

 2) To allow for background transfers in multitasking systems.
    I use wget for http and ftp transfers via the external command.

 3) To allow for new URLs to be used through lynx.
    URLs can be made up such as mymail: to spawn desired applications
    via the external command.

 See lynx.cfg for other info.
*/

#include <LYUtils.h>

#ifdef USE_EXTERNALS

#include <HTAlert.h>
#include <LYGlobalDefs.h>
#include <LYExtern.h>
#include <LYLeaks.h>
#include <LYCurses.h>


#ifdef WIN_EX
/* 1997/10/15 (Wed) 17:39:50 */

#ifndef PATH_MAX
#define PATH_MAX	1024
#endif

#define STRING_MAX	512

/* ASCII char -> HEX digit */
#define ASC2HEXD(x) (((x) >= '0' && (x) <= '9') ?               \
		     ((x) - '0') : (toupper(x) - 'A' + 10))


/* Decodes the forms %xy in a URL to the character the hexadecimal
   code of which is xy. xy are hexadecimal digits from
   [0123456789ABCDEF] (case-insensitive). If x or y are not hex-digits
   or '%' is near '\0', the whole sequence is inserted literally. */


static char *decode_string(char *s)
{
    char *save_s;
    char *p = s;

    save_s = s;
    for (; *s; s++, p++) {
	if (*s != '%')
	    *p = *s;
	else {
	    /* Do nothing if at the end of the string. Or if the chars
	       are not hex-digits. */
	    if (!*(s + 1) || !*(s + 2)
		|| !(isxdigit(*(s + 1)) && isxdigit(*(s + 2)))) {
		*p = *s;
		continue;
	    }
	    *p = (char)((ASC2HEXD(*(s + 1)) << 4) + ASC2HEXD(*(s + 2)));
	    s += 2;
	}
    }
    *p = '\0';
    return save_s;
}
#endif	/* WIN_EX */

#ifndef STRING_MAX
#define	STRING_MAX 512
#endif

/* 1997/11/10 (Mon) 14:26:10 */
PUBLIC char *string_short ARGS2(
	char *,		str,
	int,		cut_pos)
{
    char buff[STRING_MAX];
    static char s_str[STRING_MAX];
    char *p;
    int len;

    p = str;
    len = strlen(p);

    if (len > STRING_MAX) {
	strncpy(buff, p, STRING_MAX - 1);
	buff[STRING_MAX - 1] = '\0';
	len = STRING_MAX - 1;
    } else {
	strcpy(buff, p);
    }
    if (len > (LYcols - 10)) {
	buff[cut_pos] = '.';
	buff[cut_pos + 1] = '.';
	strcpy(buff + cut_pos + 2, (buff + len) - (LYcols - 10) + cut_pos + 1);
    }
    strcpy(s_str, buff);
    return (s_str);
}

#ifdef WIN_EX
/*
 *  Quote the path to make it safe for shell command processing.
 *
 *  We use a simple technique which involves quoting the entire
 *  string using single quotes, escaping the real single quotes
 *  with double quotes. This may be gross but it seems to work.
 */
PUBLIC char * quote_pathname ARGS1(
	char *, 	pathname)
{
    size_t n = 0;
    char * result;

    if (strchr(pathname, ' ') != NULL) {
	n = strlen(pathname);
	result = (char *)malloc(n + 3);
	if (result == NULL)
	    outofmem(__FILE__, "quote_pathname");
	result[0] = '"';
	strcpy(result + 1, pathname);
	result[n+1] = '"';
	result[n+2] = '\0';
    } else {
	result = strdup(pathname);
	if (result == NULL)
	    outofmem(__FILE__, "quote_pathname");
    }
    return result;
}
#endif /* WIN_EX */

#if 0	/* old version */
void run_external_ ARGS1(char *, cmd)
{
    char *the_command = 0;
    lynx_html_item_type *ext = 0;

    for (ext = externals; ext != NULL; ext = ext->next) {

	if (ext->command != 0
	&& !strncasecomp(ext->name, cmd, strlen(ext->name))) {

	    if (no_externals && !ext->always_enabled) {
		HTUserMsg(EXTERNALS_DISABLED);
	    } else {

		HTAddParam(&the_command, ext->command, 1, cmd);
		HTEndParam(&the_command, ext->command, 1);

		HTUserMsg(the_command);

		stop_curses();
		LYSystem(the_command);
		FREE(the_command);
		start_curses();
	    }

	    break;
	}
    }

    return;
}
#endif


void run_external ARGS1(char *, c)
{
#ifdef WIN_EX
    HANDLE handle;
    int status;
    int confirmed;
    char pram_string[PATH_MAX];
    int redraw_flag;
    extern int xsystem(char *cmd);
#endif
    char *cmdbuf = NULL;
    lynx_html_item_type *externals2 = 0;

    if (externals == NULL)
	return;

#ifdef WIN_EX			/* 1998/01/26 (Mon) 09:16:13 */
    if (c == NULL) {
	HTInfoMsg("Not external command exists");
	return;
    }
#endif

    for (externals2 = externals; externals2 != NULL;
	 externals2 = externals2->next) {

#ifdef WIN_EX
	handle = GetForegroundWindow();
	CTRACE((tfp, "EXTERNAL: '%s' <==> '%s'\n", externals2->name, c));
#endif
	if (externals2->command != 0
	  && !strncasecomp(externals2->name, c, strlen(externals2->name)))
	{
	    if (no_externals && !externals2->always_enabled) {
		HTUserMsg(EXTERNALS_DISABLED);
		break;
	    }
	    /*  Too dangerous to leave any URL that may come along unquoted.
	     *  They often contain '&', ';', and '?' chars, and who knows
	     *  what else may occur.
	     *  Prevent spoofing of the shell.
	     *  Dunno how this needs to be modified for VMS or DOS. - kw
	     */
#if (defined(VMS) || defined(DOSPATH) || defined(__EMX__)) && !defined(WIN_EX)
	    HTSprintf0(&cmdbuf, externals2->command, c);
#else	/* Unix or DOS/Win: */
#if defined(WIN_EX)
	    if (*c != '\"' && strchr(c, ' ') != NULL) {
		char *cp = quote_pathname(c);
		HTSprintf0(&cmdbuf, externals2->command, cp);
		FREE(cp);
	    } else {
		LYstrncpy(pram_string, c, sizeof(pram_string)-1);
		decode_string(pram_string);
		c = pram_string;

		if (strnicmp("mailto:", c, 7) == 0) {
		    HTSprintf0(&cmdbuf, externals2->command, c + 7);
		} else if (strnicmp("telnet://", c, 9) == 0) {
		    char host[sizeof(pram_string)];
		    int last_pos;

		    strcpy(host, c + 9);
		    last_pos = strlen(host) - 1;
		    if (last_pos > 1 && host[last_pos] == '/')
			host[last_pos] = '\0';

		    HTSprintf0(&cmdbuf, externals2->command, host);
		} else if (strnicmp("file://localhost/", c, 17) == 0) {
		    char e_buff[PATH_MAX], *p;

		    p = c + 17;
		    if (strchr(p, ':') == NULL) {
			sprintf(e_buff, "%s/%s", windows_drive, p);
		    } else {
			strcpy(e_buff, p);
		    }
		    p = strrchr(e_buff, '.');
		    if (p) {
			p = strchr(p, '#');
			if (p) {
			    *p = '\0';
			}
		    }
		    if (*e_buff != '\"' && strchr(e_buff, ' ') != NULL) {
			p = quote_pathname(e_buff);
			strcpy(e_buff, p);
			FREE(p);
		    }

		    /* Less ==> short filename,
		     * less ==> long filename
		     */
		    if (isupper(externals2->command[0])) {
			HTSprintf0(&cmdbuf,
				externals2->command, HTDOS_short_name(e_buff));
		    } else {
			HTSprintf0(&cmdbuf, externals2->command, e_buff);
		    }
		} else {
		    HTSprintf0(&cmdbuf, externals2->command, c);
		}
	    }
#else	/* Unix */
	    {
		char *cp = HTQuoteParameter(c);
		HTSprintf0(&cmdbuf, externals2->command, cp);
		FREE(cp);
	    }
#endif
#endif	/* VMS */

	    if (cmdbuf != 0 && *cmdbuf != '\0') {
#ifdef WIN_EX			/* 1997/10/17 (Fri) 14:07:50 */
		int len;
		char buff[PATH_MAX];

		CTRACE((tfp, "Lynx EXTERNAL: '%s'\n", cmdbuf));
#ifdef WIN_GUI			/* 1997/11/06 (Thu) 14:17:15 */
		confirmed = MessageBox(handle, cmdbuf,
				  "Lynx (EXTERNAL COMMAND EXEC)",
		       MB_ICONQUESTION | MB_SETFOREGROUND | MB_OKCANCEL)
			    == IDCANCEL;
#else
		confirmed = HTConfirm(string_short(cmdbuf, 40)) == NO;
#endif
		if (confirmed)
		    break;

		len = strlen(cmdbuf);
		if (len > 255) {
		    sprintf(buff, "Lynx: command line too long (%d > 255)", len);
#ifdef WIN_GUI			/* 1997/11/06 (Thu) 14:17:02 */
		    MessageBox(handle, buff,
			       "Lynx (EXTERNAL COMMAND EXEC)",
			  MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_OK);
		    SetConsoleTitle("Lynx for Win32");
#else
		    HTConfirm(string_short(buff, 40));
#endif
		    break;
		} else {
		    SetConsoleTitle(cmdbuf);
		}

		if (strnicmp(cmdbuf, "start ", 6) == 0)
		    redraw_flag = FALSE;
		else
		    redraw_flag = TRUE;

		if (redraw_flag) {
		    stop_curses();
		    fflush(stdout);
		}
#else
		HTUserMsg(cmdbuf);
		stop_curses();
#endif

		/* command running. */
#ifdef WIN_EX			/* 1997/10/17 (Fri) 14:07:50 */
#ifdef __CYGWIN__
		status = system(cmdbuf);
#else
		status = xsystem(cmdbuf);
#endif
		if (status != 0) {
		    sprintf(buff,
			    "EXEC code = %04x (%2d, %2d)\r\n"
			    "'%s'",
			    status, (status / 256), (status & 0xff),
			    cmdbuf);
#ifdef SH_EX	/* WIN_GUI for ERROR only */
		    MessageBox(handle, buff,
			       "Lynx (EXTERNAL COMMAND EXEC)",
			       MB_ICONSTOP | MB_SETFOREGROUND | MB_OK);
#else
		    HTConfirm(string_short(buff, 40));
#endif		/* 1 */
		}
#else	/* Not WIN_EX */
		LYSystem(cmdbuf);
#endif	/* WIN_EX */

#if defined(WIN_EX)
		SetConsoleTitle("Lynx for Win32");
#endif

#ifdef WIN_EX
		if (redraw_flag) {
		    fflush(stdout);
		    start_curses();
		}
#else
		fflush(stdout);
		start_curses();
#endif
	    }
	    break;
	} /* end if */
    } /* end-for */

    FREE(cmdbuf);
    return;
}
#endif	/* USE_EXTERNALS */