Skip to content

Commit

Permalink
Do textCleanup, improve hash_string
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpl0itU committed Aug 23, 2022
1 parent bf3727f commit c56644e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 deletions.
26 changes: 13 additions & 13 deletions languages/english.lang
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgid "Press \\ue044 to exit."
msgstr ""

msgid "\\ue000 Yes - \\ue001 No"
msgid "\\ue000: Copy \\ue001: Back"
msgstr ""

msgid "\\ue000: Select Task \\ue001: Back"
msgid "\\ue000: Export \\ue001: Back"
msgstr ""

msgid "\\ue000: Select Game \\ue001: Back"
msgid "\\ue000: Import \\ue001: Back"
msgstr ""

msgid "\\ue000: Backup \\ue001: Back"
msgid "\\ue000: Wipe \\ue001: Back"
msgstr ""

msgid "\\ue000: Restore \\ue001: Back"
msgstr ""

msgid ""
Expand All @@ -23,22 +26,19 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "\\ue000: Restore \\ue001: Back"
msgstr ""

msgid "\\ue000: Wipe \\ue001: Back"
msgid "\\ue000: Backup \\ue001: Back"
msgstr ""

msgid "\\ue000: Import \\ue001: Back"
msgid "\\ue000: Select Game \\ue001: Back"
msgstr ""

msgid "\\ue000: Export \\ue001: Back"
msgid "\\ue000: Select Task \\ue001: Back"
msgstr ""

msgid "\\ue000: Copy \\ue001: Back"
msgid "\\ue000 Yes - \\ue001 No"
msgstr ""

msgid "Press \\ue044 to exit."
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgstr ""

#: src/main.cpp:63
Expand Down
46 changes: 23 additions & 23 deletions languages/spanish.lang
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgstr "\\ue000 Confirmar - \\ue001 Cancelar"
msgid "Press \\ue044 to exit."
msgstr "Presiona \\ue044 para salir."

msgid "\\ue000 Yes - \\ue001 No"
msgstr "\\ue000 Sí - \\ue001 No"
msgid "\\ue000: Copy \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"

msgid "\\ue000: Select Task \\ue001: Back"
msgstr "\\ue000: Seleccionar Tarea \\ue001: Atrás"
msgid "\\ue000: Export \\ue001: Back"
msgstr "\\ue000: Exportar \\ue001: Atrás"

msgid "\\ue000: Select Game \\ue001: Back"
msgstr "\\ue000: Seleccionar Juego \\ue001: Atrás"
msgid "\\ue000: Import \\ue001: Back"
msgstr "\\ue000: Importar \\ue001: Atrás"

msgid "\\ue000: Backup \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"
msgid "\\ue000: Wipe \\ue001: Back"
msgstr "\\ue000: Borrar \\ue001: Atrás"

msgid "\\ue000: Restore \\ue001: Back"
msgstr "\\ue000: Restaurar \\ue001: Atrás"

msgid ""
msgstr ""
Expand All @@ -23,23 +26,20 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "\\ue000: Restore \\ue001: Back"
msgstr "\\ue000: Restaurar \\ue001: Atrás"

msgid "\\ue000: Wipe \\ue001: Back"
msgstr "\\ue000: Borrar \\ue001: Atrás"
msgid "\\ue000: Backup \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"

msgid "\\ue000: Import \\ue001: Back"
msgstr "\\ue000: Importar \\ue001: Atrás"
msgid "\\ue000: Select Game \\ue001: Back"
msgstr "\\ue000: Seleccionar Juego \\ue001: Atrás"

msgid "\\ue000: Export \\ue001: Back"
msgstr "\\ue000: Exportar \\ue001: Atrás"
msgid "\\ue000: Select Task \\ue001: Back"
msgstr "\\ue000: Seleccionar Tarea \\ue001: Atrás"

msgid "\\ue000: Copy \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"
msgid "\\ue000 Yes - \\ue001 No"
msgstr "\\ue000 Sí - \\ue001 No"

msgid "Press \\ue044 to exit."
msgstr "Presiona \\ue044 para salir."
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgstr "\\ue000 Confirmar - \\ue001 Cancelar"

#: src/main.cpp:63
msgid "Disclaimer:"
Expand Down
32 changes: 11 additions & 21 deletions src/language/gettext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,17 @@ typedef struct _MSG {
} MSG;
static MSG *baseMSG = NULL;

#define HASHWORDBITS 32

/* Defines the so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static inline uint32_t hash_string(const char *str_param) {
uint32_t hval, g;
const char *str = str_param;

/* Compute the hash value for the given string. */
hval = 0;
while (*str != '\0') {
hval <<= 4;
hval += (uint8_t) *str++;
g = hval & ((uint32_t) 0xf << (HASHWORDBITS - 4));
if (g != 0) {
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval;
#define HASHMULTIPLIER 31 // or 37

// Hashing function from https://stackoverflow.com/a/2351171
static inline uint32_t hash_string(const char *str) {
unsigned int h;
unsigned char *p;

h = 0;
for (p = (unsigned char*)str; *p != '\0'; p++)
h = HASHMULTIPLIER * h + *p;
return h;
}

/* Expand some escape sequences found in the argument string. */
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ int main() {
free(versionList);

deinitFS();
gettextCleanUp();

OSScreenShutdown();
WHBLogFreetypeFree();
Expand Down

0 comments on commit c56644e

Please sign in to comment.