cut another 30 bytes or so off. also made atoi take negative octal/hex numbers.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1175 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
372e1f0d11
commit
7dbc2a11c8
4 changed files with 43 additions and 53 deletions
|
@ -272,9 +272,7 @@ lang_again:
|
|||
|
||||
myitoa(state_language, cur_common_strings_table->lang_id);
|
||||
|
||||
process_string_from_lang(g_caption,LANGID_CAPTION);
|
||||
|
||||
SendMessage(m_bgwnd, WM_SETTEXT, 0, (LPARAM)g_caption);
|
||||
SendMessage(m_bgwnd, WM_SETTEXT, 0, (LPARAM)process_string_from_lang(g_caption,LANGID_CAPTION));
|
||||
}
|
||||
|
||||
int NSISCALL ui_doinstall(void)
|
||||
|
@ -1001,12 +999,11 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (g_inst_section[x].name_ptr>=0)
|
||||
{
|
||||
TVINSERTSTRUCT tv;
|
||||
process_string_fromtab(ps_tmpbuf,g_inst_section[x].name_ptr);
|
||||
tv.hParent=Par;
|
||||
tv.hInsertAfter=TVI_LAST;
|
||||
tv.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
|
||||
tv.item.lParam=x;
|
||||
tv.item.pszText=ps_tmpbuf;
|
||||
tv.item.pszText=process_string_fromtab(ps_tmpbuf,g_inst_section[x].name_ptr);
|
||||
tv.item.stateMask=TVIS_STATEIMAGEMASK;
|
||||
|
||||
if (m_num_insttypes && m_whichcfg != m_num_insttypes && !(g_inst_section[x].default_state&DFS_RO))
|
||||
|
@ -1083,10 +1080,9 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (g_inst_section[x].name_ptr>=0 && ns >= 0)
|
||||
{
|
||||
TVITEM tv;
|
||||
process_string_fromtab(ps_tmpbuf,ns);
|
||||
tv.hItem=hTreeItems[x];
|
||||
tv.mask=TVIF_TEXT;
|
||||
tv.pszText=ps_tmpbuf;
|
||||
tv.pszText=process_string_fromtab(ps_tmpbuf,ns);
|
||||
TreeView_SetItem(hwndTree1,&tv);
|
||||
}
|
||||
SendMessage(hwndDlg,WM_USER+0x18,x,(LPARAM)!!(g_inst_section[x].default_state&DFS_SET));
|
||||
|
|
|
@ -126,16 +126,14 @@ static int *parms;
|
|||
|
||||
static int NSISCALL process_string_fromparm_toint(int id_)
|
||||
{
|
||||
process_string(ps_tmpbuf,GetStringFromStringTab(parms[id_]));
|
||||
return myatoi(ps_tmpbuf);
|
||||
return myatoi(process_string(ps_tmpbuf,GetStringFromStringTab(parms[id_])));
|
||||
}
|
||||
|
||||
// NB - USE CAUTION when rearranging code to make use of the new return value of
|
||||
// this function - be sure the parm being accessed is not modified before the call.
|
||||
static char * NSISCALL process_string_fromparm_tobuf(int id_)
|
||||
{
|
||||
process_string_fromtab(bufs[id_ >> 4], parms[id_ & 0xF]);
|
||||
return bufs[id_ >> 4];
|
||||
return process_string_fromtab(bufs[id_ >> 4], parms[id_ & 0xF]);
|
||||
}
|
||||
|
||||
// returns EXEC_ERROR on error
|
||||
|
|
|
@ -365,15 +365,14 @@ static void NSISCALL queryShellFolders(const char *name_, char *out)
|
|||
char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
||||
|
||||
|
||||
void NSISCALL process_string_fromtab(char *out, int offs)
|
||||
char * NSISCALL process_string_fromtab(char *out, int offs)
|
||||
{
|
||||
process_string(ps_tmpbuf,GetStringFromStringTab(offs));
|
||||
lstrcpyn(out,ps_tmpbuf,NSIS_MAX_STRLEN);
|
||||
return lstrcpyn(out,process_string(ps_tmpbuf,GetStringFromStringTab(offs)),NSIS_MAX_STRLEN);
|
||||
}
|
||||
|
||||
void NSISCALL process_string_from_lang(char *out, langid_t id)
|
||||
char * NSISCALL process_string_from_lang(char *out, langid_t id)
|
||||
{
|
||||
process_string_fromtab(out, GetLangString(id));
|
||||
return process_string_fromtab(out, GetLangString(id));
|
||||
}
|
||||
|
||||
// Retrieve the string offset associated with the language string ID given
|
||||
|
@ -389,45 +388,41 @@ void NSISCALL myitoa(char *s, int d) { wsprintf(s,"%d",d); }
|
|||
int NSISCALL myatoi(char *s)
|
||||
{
|
||||
unsigned int v=0;
|
||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
||||
int sign=0; // sign of positive
|
||||
char m=10; // base of 0
|
||||
char t='9'; // cap top of numbers at 9
|
||||
|
||||
if (*s == '-')
|
||||
{
|
||||
s++; //skip over -
|
||||
sign++; // sign flip
|
||||
}
|
||||
|
||||
if (*s == '0')
|
||||
{
|
||||
s+=2;
|
||||
for (;;)
|
||||
s++; // skip over 0
|
||||
if (s[0] >= '0' && s[0] <= '7')
|
||||
{
|
||||
int c=*s++;
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
else if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') c = (c & 7) + 9;
|
||||
else break;
|
||||
v<<=4;
|
||||
v+=c;
|
||||
m=8; // base of 8
|
||||
t='7'; // cap top at 7
|
||||
}
|
||||
if (s[0] == 'x' || s[0] == 'X')
|
||||
{
|
||||
m=16; // base of 16
|
||||
s++; // advance over 'x'
|
||||
}
|
||||
}
|
||||
else if (*s == '0' && s[1] >= '0' && s[1] <= '7')
|
||||
|
||||
for (;;)
|
||||
{
|
||||
s++;
|
||||
for (;;)
|
||||
{
|
||||
int c=*s++;
|
||||
if (c >= '0' && c <= '7') c-='0';
|
||||
else break;
|
||||
v<<=3;
|
||||
v+=c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int sign=0;
|
||||
if (*s == '-') { s++; sign++; }
|
||||
for (;;)
|
||||
{
|
||||
int c=*s++;
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
else break;
|
||||
v*=10;
|
||||
v+=c;
|
||||
}
|
||||
if (sign) return -(int) v;
|
||||
int c=*s++;
|
||||
if (c >= '0' && c <= t) c-='0';
|
||||
else if (m==16 && (c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') c = (c & 7) + 9;
|
||||
else break;
|
||||
v*=m;
|
||||
v+=c;
|
||||
}
|
||||
if (sign) return -(int) v;
|
||||
return (int)v;
|
||||
}
|
||||
|
||||
|
@ -445,7 +440,7 @@ int NSISCALL mystrlen(const char *in)
|
|||
}
|
||||
|
||||
// Dave Laundon's simplified process_string
|
||||
void NSISCALL process_string(char *out, const char *in)
|
||||
char * NSISCALL process_string(char *out, const char *in)
|
||||
{
|
||||
char *outsave = out;
|
||||
while (*in && out - outsave < NSIS_MAX_STRLEN)
|
||||
|
@ -557,6 +552,7 @@ void NSISCALL process_string(char *out, const char *in)
|
|||
} // >= VAR_CODES_START
|
||||
} // while
|
||||
*out = 0;
|
||||
return outsave;
|
||||
}
|
||||
#ifdef NSIS_CONFIG_LOG
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
void NSISCALL recursive_create_directory(char *directory);
|
||||
|
||||
extern char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
||||
void NSISCALL process_string(char *out, const char *in);
|
||||
void NSISCALL process_string_fromtab(char *out, int offs);
|
||||
void NSISCALL process_string_from_lang(char *out, langid_t id);
|
||||
char * NSISCALL process_string(char *out, const char *in);
|
||||
char * NSISCALL process_string_fromtab(char *out, int offs);
|
||||
char * NSISCALL process_string_from_lang(char *out, langid_t id);
|
||||
int NSISCALL GetLangString(langid_t id);
|
||||
void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out);
|
||||
int NSISCALL myatoi(char *s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue