if (*from_ptr == ',')
break;
- /* the user's real name may contain 'ß' characters (german sharp s),
+ /* the user's real name may contain 'german sharp s' characters,
which have no equivalent in upper case letters (used by our fonts) */
- if (*from_ptr == 'ß')
+ if (*from_ptr == CHAR_BYTE_SHARP_S)
{
from_ptr++;
*to_ptr++ = 's';
char *getStringCat2WithSeparator(char *s1, char *s2, char *sep)
{
+ if (s1 == NULL || s2 == NULL || sep == NULL)
+ return NULL;
+
char *complete_string = checked_malloc(strlen(s1) + strlen(sep) +
strlen(s2) + 1);
char *getStringCat3WithSeparator(char *s1, char *s2, char *s3, char *sep)
{
+ if (s1 == NULL || s2 == NULL || s3 == NULL || sep == NULL)
+ return NULL;
+
char *complete_string = checked_malloc(strlen(s1) + strlen(sep) +
strlen(s2) + strlen(sep) +
strlen(s3) + 1);
return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
+char *getImg2(char *path1, char *path2)
+{
+ char *filename = getPath2(path1, path2);
+
+ if (!fileExists(filename) && strSuffix(path2, ".png"))
+ {
+ // backward compatibility: if PNG file not found, check for PCX file
+ char *path2pcx = getStringCopy(path2);
+
+ strcpy(&path2pcx[strlen(path2pcx) - 3], "pcx");
+
+ free(filename);
+
+ filename = getPath2(path1, path2pcx);
+
+ free(path2pcx);
+ }
+
+ return filename;
+}
+
+char *getImg3(char *path1, char *path2, char *path3)
+{
+ char *filename = getPath3(path1, path2, path3);
+
+ if (!fileExists(filename) && strSuffix(path3, ".png"))
+ {
+ // backward compatibility: if PNG file not found, check for PCX file
+ char *path3pcx = getStringCopy(path3);
+
+ strcpy(&path3pcx[strlen(path3pcx) - 3], "pcx");
+
+ free(filename);
+
+ filename = getPath3(path1, path2, path3pcx);
+
+ free(path3pcx);
+ }
+
+ return filename;
+}
+
char *getStringCopy(const char *s)
{
char *s_copy;
options.network = FALSE;
options.verbose = FALSE;
options.debug = FALSE;
- options.debug_x11_sync = FALSE;
#if 1
options.verbose = TRUE;
{
options.debug = TRUE;
}
- else if (strncmp(option, "-debug-x11-sync", option_len) == 0)
- {
- options.debug_x11_sync = TRUE;
- }
else if (strncmp(option, "-verbose", option_len) == 0)
{
options.verbose = TRUE;
if (mode & ERR_WARN)
fprintf_nonewline(program.error_file, "warning: ");
+ if (mode & ERR_EXIT)
+ fprintf_nonewline(program.error_file, "fatal error: ");
+
va_start(ap, format);
vfprintf_newline(program.error_file, format, ap);
va_end(ap);
{ KSYM_braceright, "XK_braceright", "brace right" },
{ KSYM_asciitilde, "XK_asciitilde", "~" },
- /* special (non-ASCII) keys (ISO-Latin-1) */
- { KSYM_degree, "XK_degree", "°" },
- { KSYM_Adiaeresis, "XK_Adiaeresis", "Ä" },
- { KSYM_Odiaeresis, "XK_Odiaeresis", "Ö" },
- { KSYM_Udiaeresis, "XK_Udiaeresis", "Ü" },
- { KSYM_adiaeresis, "XK_adiaeresis", "ä" },
- { KSYM_odiaeresis, "XK_odiaeresis", "ö" },
- { KSYM_udiaeresis, "XK_udiaeresis", "ü" },
+ /* special (non-ASCII) keys */
+ { KSYM_degree, "XK_degree", "degree" },
+ { KSYM_Adiaeresis, "XK_Adiaeresis", "A umlaut" },
+ { KSYM_Odiaeresis, "XK_Odiaeresis", "O umlaut" },
+ { KSYM_Udiaeresis, "XK_Udiaeresis", "U umlaut" },
+ { KSYM_adiaeresis, "XK_adiaeresis", "a umlaut" },
+ { KSYM_odiaeresis, "XK_odiaeresis", "o umlaut" },
+ { KSYM_udiaeresis, "XK_udiaeresis", "u umlaut" },
{ KSYM_ssharp, "XK_ssharp", "sharp s" },
#if defined(TARGET_SDL2)
char getCharFromKey(Key key)
{
+ static struct
+ {
+ Key key;
+ byte key_char;
+ } translate_key_char[] =
+ {
+ /* special (non-ASCII) keys (ISO-8859-1) */
+ { KSYM_degree, CHAR_BYTE_DEGREE },
+ { KSYM_Adiaeresis, CHAR_BYTE_UMLAUT_A },
+ { KSYM_Odiaeresis, CHAR_BYTE_UMLAUT_O },
+ { KSYM_Udiaeresis, CHAR_BYTE_UMLAUT_U },
+ { KSYM_adiaeresis, CHAR_BYTE_UMLAUT_a },
+ { KSYM_odiaeresis, CHAR_BYTE_UMLAUT_o },
+ { KSYM_udiaeresis, CHAR_BYTE_UMLAUT_u },
+ { KSYM_ssharp, CHAR_BYTE_SHARP_S },
+
+ /* end-of-array identifier */
+ { 0, 0 }
+ };
+
char *keyname = getKeyNameFromKey(key);
char c = 0;
c = keyname[0];
else if (strEqual(keyname, "space"))
c = ' ';
+ else
+ {
+ int i = 0;
+
+ do
+ {
+ if (key == translate_key_char[i].key)
+ {
+ c = translate_key_char[i].key_char;
+
+ break;
+ }
+ }
+ while (translate_key_char[++i].key_char);
+ }
return c;
}
if (dir_name == NULL)
return FALSE;
- boolean success = (access(dir_name, F_OK) == 0);
+ struct stat file_status;
+ boolean success = (stat(dir_name, &file_status) == 0 &&
+ (file_status.st_mode & S_IFMT) == S_IFDIR);
#if defined(PLATFORM_ANDROID)
if (!success)
return FALSE;
}
-static boolean FileCouldBeArtwork(char *basename)
+static boolean FileCouldBeArtwork(char *filename)
{
+ char *basename = getBaseNamePtr(filename);
+
return (!strEqual(basename, ".") &&
!strEqual(basename, "..") &&
!fileHasSuffix(basename, "txt") &&
- !fileHasSuffix(basename, "conf"));
+ !fileHasSuffix(basename, "conf") &&
+ !directoryExists(filename));
}
boolean FileIsGraphic(char *filename)
{
- char *basename = getBaseNamePtr(filename);
-
- return FileCouldBeArtwork(basename);
+ return FileCouldBeArtwork(filename);
}
boolean FileIsSound(char *filename)
{
- char *basename = getBaseNamePtr(filename);
-
- return FileCouldBeArtwork(basename);
+ return FileCouldBeArtwork(filename);
}
boolean FileIsMusic(char *filename)
{
- char *basename = getBaseNamePtr(filename);
-
- return FileCouldBeArtwork(basename);
+ return FileCouldBeArtwork(filename);
}
-boolean FileIsArtworkType(char *basename, int type)
+boolean FileIsArtworkType(char *filename, int type)
{
- if ((type == TREE_TYPE_GRAPHICS_DIR && FileIsGraphic(basename)) ||
- (type == TREE_TYPE_SOUNDS_DIR && FileIsSound(basename)) ||
- (type == TREE_TYPE_MUSIC_DIR && FileIsMusic(basename)))
+ if ((type == TREE_TYPE_GRAPHICS_DIR && FileIsGraphic(filename)) ||
+ (type == TREE_TYPE_SOUNDS_DIR && FileIsSound(filename)) ||
+ (type == TREE_TYPE_MUSIC_DIR && FileIsMusic(filename)))
return TRUE;
return FALSE;