-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add svn property svn:eol-style native to new files. Has the side effe…
…ct of fixing the eol markers as needed. No functional changes anywhere.
- Loading branch information
Showing
4 changed files
with
726 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,82 @@ | ||
|
||
|
||
// Compiler implementation of the D programming language | ||
// Copyright (c) 2010 by Digital Mars | ||
// All Rights Reserved | ||
// written by Walter Bright | ||
// http://www.digitalmars.com | ||
// License for redistribution is by either the Artistic License | ||
// in artistic.txt, or the GNU General Public License in gnu.txt. | ||
// See the included readme.txt for details. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
/****************************************** | ||
* Looks for undefined identifier s to see | ||
* if it might be undefined because an import | ||
* was not specified. | ||
* Not meant to be a comprehensive list of names in each module, | ||
* just the most common ones. | ||
*/ | ||
|
||
const char *importHint(const char *s) | ||
{ | ||
#if DMDV1 | ||
static const char *modules[] = | ||
{ "std.c.stdio", | ||
"std.stdio", | ||
"std.math", | ||
}; | ||
static const char *names[] = | ||
{ | ||
"printf", NULL, | ||
"writefln", NULL, | ||
"sin", "cos", "sqrt", "fabs", NULL, | ||
}; | ||
#else | ||
static const char *modules[] = | ||
{ "core.stdc.stdio", | ||
"std.stdio", | ||
"std.math", | ||
}; | ||
static const char *names[] = | ||
{ | ||
"printf", NULL, | ||
"writeln", NULL, | ||
"sin", "cos", "sqrt", "fabs", NULL, | ||
}; | ||
#endif | ||
int m = 0; | ||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) | ||
{ | ||
const char *p = names[n]; | ||
if (p == NULL) | ||
{ m++; | ||
continue; | ||
} | ||
assert(m < sizeof(modules)/sizeof(modules[0])); | ||
if (strcmp(s, p) == 0) | ||
return modules[m]; | ||
} | ||
return NULL; // didn't find it | ||
} | ||
|
||
#if UNITTEST | ||
|
||
void unittest_importHint() | ||
{ | ||
const char *p; | ||
|
||
p = importHint("printf"); | ||
assert(p); | ||
p = importHint("fabs"); | ||
assert(p); | ||
p = importHint("xxxxx"); | ||
assert(!p); | ||
} | ||
|
||
#endif | ||
|
||
|
||
// Compiler implementation of the D programming language | ||
// Copyright (c) 2010 by Digital Mars | ||
// All Rights Reserved | ||
// written by Walter Bright | ||
// http://www.digitalmars.com | ||
// License for redistribution is by either the Artistic License | ||
// in artistic.txt, or the GNU General Public License in gnu.txt. | ||
// See the included readme.txt for details. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
/****************************************** | ||
* Looks for undefined identifier s to see | ||
* if it might be undefined because an import | ||
* was not specified. | ||
* Not meant to be a comprehensive list of names in each module, | ||
* just the most common ones. | ||
*/ | ||
|
||
const char *importHint(const char *s) | ||
{ | ||
#if DMDV1 | ||
static const char *modules[] = | ||
{ "std.c.stdio", | ||
"std.stdio", | ||
"std.math", | ||
}; | ||
static const char *names[] = | ||
{ | ||
"printf", NULL, | ||
"writefln", NULL, | ||
"sin", "cos", "sqrt", "fabs", NULL, | ||
}; | ||
#else | ||
static const char *modules[] = | ||
{ "core.stdc.stdio", | ||
"std.stdio", | ||
"std.math", | ||
}; | ||
static const char *names[] = | ||
{ | ||
"printf", NULL, | ||
"writeln", NULL, | ||
"sin", "cos", "sqrt", "fabs", NULL, | ||
}; | ||
#endif | ||
int m = 0; | ||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) | ||
{ | ||
const char *p = names[n]; | ||
if (p == NULL) | ||
{ m++; | ||
continue; | ||
} | ||
assert(m < sizeof(modules)/sizeof(modules[0])); | ||
if (strcmp(s, p) == 0) | ||
return modules[m]; | ||
} | ||
return NULL; // didn't find it | ||
} | ||
|
||
#if UNITTEST | ||
|
||
void unittest_importHint() | ||
{ | ||
const char *p; | ||
|
||
p = importHint("printf"); | ||
assert(p); | ||
p = importHint("fabs"); | ||
assert(p); | ||
p = importHint("xxxxx"); | ||
assert(!p); | ||
} | ||
|
||
#endif |
Oops, something went wrong.