added my_strtod(), as replacement for Win32 strtod()
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@99 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
ef51fc436e
commit
59a7979f32
54
src/win32.c
54
src/win32.c
@ -27,10 +27,18 @@
|
||||
|
||||
#ifdef GEANY_WIN32
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "win32.h"
|
||||
|
||||
#include "document.h"
|
||||
#include "support.h"
|
||||
#include "utils.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
|
||||
//static gchar appfontname[128] = "tahoma 8"; /* fallback value */
|
||||
@ -189,7 +197,7 @@ void win32_show_file_dialog(gboolean file_open)
|
||||
of.lpstrDefExt = "c";
|
||||
if (file_open)
|
||||
{
|
||||
of.Flags = OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_EXPLORER;
|
||||
of.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST | OFN_EXPLORER;
|
||||
retval = GetOpenFileName(&of);
|
||||
}
|
||||
else
|
||||
@ -224,7 +232,8 @@ void win32_show_file_dialog(gboolean file_open)
|
||||
}
|
||||
else
|
||||
{
|
||||
document_open_file(-1, fname, 0);
|
||||
document_open_file(-1, fname, 0, of.Flags & OFN_READONLY);
|
||||
dialogs_show_info("%s", utils_btoa(of.Flags & OFN_READONLY));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -238,7 +247,7 @@ void win32_show_file_dialog(gboolean file_open)
|
||||
break;
|
||||
|
||||
g_snprintf(file_name, 254, "%s\\%s", fname, fname + x + 1);
|
||||
document_open_file(-1, file_name, 0);
|
||||
document_open_file(-1, file_name, 0, of.Flags & OFN_READONLY);
|
||||
}
|
||||
x++;
|
||||
}
|
||||
@ -393,4 +402,43 @@ void win32_show_pref_file_dialog(GtkEntry *item)
|
||||
}
|
||||
|
||||
|
||||
double my_strtod(const char *source, char **end)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned short tmp;
|
||||
double exp, result;
|
||||
|
||||
// input should be 0x... or 0X...
|
||||
if (strlen(source) < 3 || source[0] != '0' || (source[1] != 'x' && source[1] != 'X'))
|
||||
return -1.0;
|
||||
source += 2;
|
||||
|
||||
exp = 0.0;
|
||||
result = 0;
|
||||
for (i = (strlen(source) - 1); i >= 0; i--)
|
||||
{
|
||||
if (isdigit(source[i]))
|
||||
{ // convert the char to a real digit
|
||||
tmp = source[i] - '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isxdigit(source[i]))
|
||||
{ // convert the char to a real digit
|
||||
if (source[i] > 70)
|
||||
tmp = source[i] - 'W';
|
||||
else
|
||||
tmp = source[i] - '7';
|
||||
}
|
||||
// stop if a non xdigit was found
|
||||
else break;
|
||||
}
|
||||
|
||||
result += pow(16.0, exp) * tmp;
|
||||
exp++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -41,4 +41,6 @@ void win32_show_font_dialog(void);
|
||||
|
||||
void win32_show_color_dialog(void);
|
||||
|
||||
double my_strtod(const char *source, char **end);
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user