summaryrefslogtreecommitdiff
path: root/iup/src
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src')
-rwxr-xr-xiup/src/iup_str.c25
-rwxr-xr-xiup/src/iup_str.h5
-rwxr-xr-xiup/src/win/iupwin_text.c8
3 files changed, 13 insertions, 25 deletions
diff --git a/iup/src/iup_str.c b/iup/src/iup_str.c
index 5f5b85d..6ca8c1b 100755
--- a/iup/src/iup_str.c
+++ b/iup/src/iup_str.c
@@ -558,36 +558,25 @@ void iupStrToUnix(char* str)
*pstr = *str;
}
-char* iupStrToMac(const char* str)
+void iupStrToMac(char* str)
{
- int at_start = 1;
- char* pstr, *new_str;
-
- if (!str) return NULL;
-
- if (iupStrLineCount(str) == 1)
- return (char*)str;
+ char* pstr = str;
- new_str = iupStrDup(str);
- str = new_str;
- pstr = new_str;
+ if (!str) return;
while (*str)
{
- if (*str == '\n')
+ if (*str == '\r')
{
- if (!at_start && *(str-1) != '\r') /* UNIX line end */
- *pstr++ = '\r';
- str++;
+ if (*(++str) == '\n') /* DOS line end */
+ str++;
+ *pstr++ = '\r';
}
else
*pstr++ = *str++;
- at_start = 0;
}
*pstr = *str;
-
- return new_str;
}
char* iupStrToDos(const char* str)
diff --git a/iup/src/iup_str.h b/iup/src/iup_str.h
index 1c2e7a5..e7599fb 100755
--- a/iup/src/iup_str.h
+++ b/iup/src/iup_str.h
@@ -150,10 +150,9 @@ int iupStrReplace(char* str, char src, char dst);
* \ingroup str */
void iupStrToUnix(char* str);
-/** Convert line ends to MAC format (one \r per line).
- * If returned pointer different than input it must be freed.
+/** Convert line ends to MAC format in place (one \r per line).
* \ingroup str */
-char* iupStrToMac(const char* str);
+void iupStrToMac(char* str);
/** Convert line ends to DOS/Windows format (the sequence \r\n per line).
* If returned pointer different than input it must be freed.
diff --git a/iup/src/win/iupwin_text.c b/iup/src/win/iupwin_text.c
index 2a61724..c0e7115 100755
--- a/iup/src/win/iupwin_text.c
+++ b/iup/src/win/iupwin_text.c
@@ -608,7 +608,7 @@ static int winTextSetValueAttrib(Ihandle* ih, const char* value)
if (ih->data->is_multiline)
{
if (ih->data->has_formatting)
- str = iupStrToMac(str);
+ iupStrToMac(str);
else
str = iupStrToDos(str);
}
@@ -662,7 +662,7 @@ static int winTextSetSelectedTextAttrib(Ihandle* ih, const char* value)
if (ih->data->is_multiline)
{
if (ih->data->has_formatting)
- str = iupStrToMac(str);
+ iupStrToMac(str);
else
str = iupStrToDos(str);
}
@@ -860,7 +860,7 @@ static int winTextSetInsertAttrib(Ihandle* ih, const char* value)
if (ih->data->is_multiline)
{
if (ih->data->has_formatting)
- str = iupStrToMac(str);
+ iupStrToMac(str);
else
str = iupStrToDos(str);
}
@@ -883,7 +883,7 @@ static int winTextSetAppendAttrib(Ihandle* ih, const char* value)
if (ih->data->is_multiline)
{
if (ih->data->has_formatting)
- str = iupStrToMac(str);
+ iupStrToMac(str);
else
str = iupStrToDos(str);
}