Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: tools/re2c/code.c

Issue 10324002: Merge https://github.com/yasm/yasm/commit/ab19547382660d81e0b4a0232dccb38f44c52a36 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/yasm/patched-yasm/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifdef _WIN32
2 #include <windows.h>
3 #include <io.h>
4 #endif
1 #include <stdlib.h> 5 #include <stdlib.h>
2 #include <string.h> 6 #include <string.h>
3 #include <ctype.h> 7 #include <ctype.h>
4 #include "tools/re2c/substr.h" 8 #include "tools/re2c/substr.h"
5 #include "tools/re2c/globals.h" 9 #include "tools/re2c/globals.h"
6 #include "tools/re2c/dfa.h" 10 #include "tools/re2c/dfa.h"
7 #include "tools/re2c/parse.h" 11 #include "tools/re2c/parse.h"
8 12
13 #ifdef _WIN32
14 /* tmpfile() replacment for Windows.
15 *
16 * On Windows tmpfile() creates the file in the root directory. This
17 * may fail due to unsufficient privileges.
18 */
19 static FILE *
20 win32_tmpfile (void)
21 {
22 DWORD path_len;
23 WCHAR path_name[MAX_PATH + 1];
24 WCHAR file_name[MAX_PATH + 1];
25 HANDLE handle;
26 int fd;
27 FILE *fp;
28
29 path_len = GetTempPathW (MAX_PATH, path_name);
30 if (path_len <= 0 || path_len >= MAX_PATH)
31 return NULL;
Nico 2012/05/02 16:52:05 This indent looks different from the upstream patc
scottmg 2012/05/02 16:58:23 The pretty diff page on github isn't replacing tab
32
33 if (GetTempFileNameW (path_name, L"ps_", 0, file_name) == 0)
34 return NULL;
35
36 handle = CreateFileW (file_name,
37 GENERIC_READ | GENERIC_WRITE,
38 0,
39 NULL,
40 CREATE_ALWAYS,
41 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE,
42 NULL);
43 if (handle == INVALID_HANDLE_VALUE) {
44 DeleteFileW (file_name);
45 return NULL;
46 }
47
48 fd = _open_osfhandle((intptr_t) handle, 0);
49 if (fd < 0) {
50 CloseHandle (handle);
51 return NULL;
52 }
53
54 fp = fdopen(fd, "w+b");
55 if (fp == NULL) {
56 _close(fd);
57 return NULL;
58 }
59
60 return fp;
61 }
62 #endif
63
9 static void useLabel(size_t value) { 64 static void useLabel(size_t value) {
10 while (value >= vUsedLabelAlloc) { 65 while (value >= vUsedLabelAlloc) {
11 vUsedLabels = realloc(vUsedLabels, vUsedLabelAlloc * 2); 66 vUsedLabels = realloc(vUsedLabels, vUsedLabelAlloc * 2);
12 if (!vUsedLabels) { 67 if (!vUsedLabels) {
13 fputs("Out of memory.\n", stderr); 68 fputs("Out of memory.\n", stderr);
14 exit(EXIT_FAILURE); 69 exit(EXIT_FAILURE);
15 } 70 }
16 memset(vUsedLabels + vUsedLabelAlloc, 0, vUsedLabelAlloc); 71 memset(vUsedLabels + vUsedLabelAlloc, 0, vUsedLabelAlloc);
17 vUsedLabelAlloc *= 2; 72 vUsedLabelAlloc *= 2;
18 } 73 }
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 start_label = label; 892 start_label = label;
838 893
839 Action_new_Enter(d->head, label++); 894 Action_new_Enter(d->head, label++);
840 895
841 for(s = d->head; s; s = s->next) 896 for(s = d->head; s; s = s->next)
842 s->label = label++; 897 s->label = label++;
843 898
844 nOrgOline = oline; 899 nOrgOline = oline;
845 maxFillIndexes = vFillIndexes; 900 maxFillIndexes = vFillIndexes;
846 orgVFillIndexes = vFillIndexes; 901 orgVFillIndexes = vFillIndexes;
902 #ifdef _WIN32
903 tmpo = win32_tmpfile();
904 #else
847 tmpo = tmpfile(); 905 tmpo = tmpfile();
906 #endif
848 for(s = d->head; s; s = s->next){ 907 for(s = d->head; s; s = s->next){
849 int readCh = 0; 908 int readCh = 0;
850 State_emit(s, tmpo, &readCh); 909 State_emit(s, tmpo, &readCh);
851 Go_genGoto(&s->go, tmpo, s, s->next, &readCh); 910 Go_genGoto(&s->go, tmpo, s, s->next, &readCh);
852 } 911 }
853 fclose(tmpo); 912 fclose(tmpo);
854 maxFillIndexes = vFillIndexes; 913 maxFillIndexes = vFillIndexes;
855 vFillIndexes = orgVFillIndexes; 914 vFillIndexes = orgVFillIndexes;
856 oline = nOrgOline; 915 oline = nOrgOline;
857 916
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 if (bitmap_brace) { 960 if (bitmap_brace) {
902 fputs("}\n", o); 961 fputs("}\n", o);
903 oline++; 962 oline++;
904 } 963 }
905 964
906 BitMap_first = NULL; 965 BitMap_first = NULL;
907 966
908 free(saves); 967 free(saves);
909 free(rules); 968 free(rules);
910 } 969 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698