Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
f91e5825
Commit
f91e5825
authored
Aug 27, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
Aug 27, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use buffers rather than linked lists for input and out buffers.
Stop reading input at a nul byte.
parent
62bffe46
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
259 deletions
+45
-259
Makefile.in
dlls/richedit/Makefile.in
+0
-1
charlist.c
dlls/richedit/charlist.c
+0
-130
charlist.h
dlls/richedit/charlist.h
+0
-45
reader.c
dlls/richedit/reader.c
+12
-19
richedit.c
dlls/richedit/richedit.c
+4
-13
rtf.h
dlls/richedit/rtf.h
+9
-5
text-writer.c
dlls/richedit/text-writer.c
+20
-46
No files found.
dlls/richedit/Makefile.in
View file @
f91e5825
...
...
@@ -6,7 +6,6 @@ MODULE = riched32.dll
IMPORTS
=
user32 kernel32
C_SRCS
=
\
charlist.c
\
reader.c
\
text-writer.c
\
richedit.c
...
...
dlls/richedit/charlist.c
deleted
100644 → 0
View file @
62bffe46
/*
*
* Character List
*
* Copyright (c) 2000 by Jean-Claude Batista
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include "charlist.h"
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
richedit
);
extern
HANDLE
RICHED32_hHeap
;
void
CHARLIST_Enqueue
(
CHARLIST
*
pCharList
,
char
myChar
)
{
CHARLISTENTRY
*
pNewEntry
=
HeapAlloc
(
RICHED32_hHeap
,
0
,
sizeof
(
CHARLISTENTRY
));
pNewEntry
->
pNext
=
NULL
;
pNewEntry
->
myChar
=
myChar
;
TRACE
(
"
\n
"
);
if
(
pCharList
->
pTail
==
NULL
)
{
pCharList
->
pHead
=
pCharList
->
pTail
=
pNewEntry
;
}
else
{
CHARLISTENTRY
*
pCurrent
=
pCharList
->
pTail
;
pCharList
->
pTail
=
pCurrent
->
pNext
=
pNewEntry
;
}
pCharList
->
nCount
++
;
}
char
CHARLIST_Dequeue
(
CHARLIST
*
pCharList
)
{
CHARLISTENTRY
*
pCurrent
;
char
myChar
;
TRACE
(
"
\n
"
);
if
(
pCharList
->
nCount
==
0
)
return
0
;
pCharList
->
nCount
--
;
myChar
=
pCharList
->
pHead
->
myChar
;
pCurrent
=
pCharList
->
pHead
->
pNext
;
HeapFree
(
RICHED32_hHeap
,
0
,
pCharList
->
pHead
);
if
(
pCharList
->
nCount
==
0
)
{
pCharList
->
pHead
=
pCharList
->
pTail
=
NULL
;
}
else
{
pCharList
->
pHead
=
pCurrent
;
}
return
myChar
;
}
int
CHARLIST_GetNbItems
(
CHARLIST
*
pCharList
)
{
TRACE
(
"
\n
"
);
return
pCharList
->
nCount
;
}
void
CHARLIST_FreeList
(
CHARLIST
*
pCharList
){
TRACE
(
"
\n
"
);
while
(
pCharList
->
nCount
)
CHARLIST_Dequeue
(
pCharList
);
}
/* this function counts the number of occurrences of a caracter */
int
CHARLIST_CountChar
(
CHARLIST
*
pCharList
,
char
myChar
)
{
CHARLISTENTRY
*
pCurrent
;
int
nCount
=
0
;
TRACE
(
"
\n
"
);
for
(
pCurrent
=
pCharList
->
pHead
;
pCurrent
;
pCurrent
=
pCurrent
->
pNext
)
if
(
pCurrent
->
myChar
==
myChar
)
nCount
++
;
return
nCount
;
}
int
CHARLIST_toBuffer
(
CHARLIST
*
pCharList
,
char
*
pBuffer
,
int
nBufferSize
)
{
TRACE
(
"
\n
"
);
/* we add one to store a NULL caracter */
if
(
nBufferSize
<
pCharList
->
nCount
+
1
)
return
pCharList
->
nCount
;
for
(;
pCharList
->
nCount
;
pBuffer
++
)
*
pBuffer
=
CHARLIST_Dequeue
(
pCharList
);
*
pBuffer
=
'\0'
;
return
0
;
}
dlls/richedit/charlist.h
deleted
100644 → 0
View file @
62bffe46
/*
* Character List
*
* Copyright (c) 2000 by Jean-Claude Batista
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _CHARLIST
#define _CHARLIST
typedef
struct
_tagCHARLISTENTRY
{
struct
_tagCHARLISTENTRY
*
pNext
;
char
myChar
;
}
CHARLISTENTRY
;
typedef
struct
_tagCHARLIST
{
unsigned
int
nCount
;
/* Entries Count; */
CHARLISTENTRY
*
pHead
;
CHARLISTENTRY
*
pTail
;
}
CHARLIST
;
void
CHARLIST_Enqueue
(
CHARLIST
*
pCharList
,
char
myChar
);
char
CHARLIST_Dequeue
(
CHARLIST
*
pCharList
);
int
CHARLIST_GetNbItems
(
CHARLIST
*
pCharList
);
void
CHARLIST_FreeList
(
CHARLIST
*
pCharList
);
int
CHARLIST_CountChar
(
CHARLIST
*
pCharList
,
char
myChar
);
int
CHARLIST_toBuffer
(
CHARLIST
*
pCharList
,
char
*
pBuffer
,
int
nBufferSize
);
#endif
dlls/richedit/reader.c
View file @
f91e5825
...
...
@@ -80,8 +80,6 @@
#include <stdlib.h>
#include "charlist.h"
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
...
...
@@ -118,28 +116,23 @@ static void ReadCharSetMaps (RTF_Info *);
int
_RTFGetChar
(
RTF_Info
*
info
)
{
char
myChar
;
int
ch
;
TRACE
(
"
\n
"
);
if
(
CHARLIST_GetNbItems
(
&
info
->
inputCharList
)
==
0
)
if
(
info
->
dwInputSize
<=
info
->
dwInputUsed
)
{
char
buff
[
4096
];
long
pcb
;
info
->
editstream
.
pfnCallback
(
info
->
editstream
.
dwCookie
,
buff
,
sizeof
(
buff
),
&
pcb
);
if
(
pcb
==
0
)
return
EOF
;
else
{
int
i
;
for
(
i
=
0
;
i
<
pcb
;
i
++
)
{
CHARLIST_Enqueue
(
&
info
->
inputCharList
,
buff
[
i
]);
}
}
long
count
=
0
;
info
->
editstream
.
pfnCallback
(
info
->
editstream
.
dwCookie
,
info
->
InputBuffer
,
sizeof
(
info
->
InputBuffer
),
&
count
);
if
(
count
==
0
)
return
EOF
;
info
->
dwInputSize
=
count
;
info
->
dwInputUsed
=
0
;
}
myChar
=
CHARLIST_Dequeue
(
&
info
->
inputCharList
);
return
(
int
)
myChar
;
ch
=
info
->
InputBuffer
[
info
->
dwInputUsed
++
];
if
(
!
ch
)
return
EOF
;
return
ch
;
}
void
RTFSetEditStream
(
RTF_Info
*
info
,
EDITSTREAM
*
es
)
...
...
dlls/richedit/richedit.c
View file @
f91e5825
...
...
@@ -31,7 +31,6 @@
#include "winerror.h"
#include "riched32.h"
#include "richedit.h"
#include "charlist.h"
#define NO_SHLWAPI_STREAM
#include "shlwapi.h"
...
...
@@ -115,11 +114,9 @@ typedef struct _RTFControl_info
static
LRESULT
WINAPI
RICHED32_WindowProc
(
HWND
hwnd
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
int
RTFToBuffer
(
RTF_Info
*
parser
,
char
*
pBuffer
,
int
nBufferSize
);
LONG
newstyle
=
0
;
LONG
style
=
0
;
RTFControl_Info
*
info
;
int
rtfBufferSize
;
CHARRANGE
*
cr
;
info
=
(
RTFControl_Info
*
)
GetWindowLongW
(
hwnd
,
RTFInfoOffset
);
...
...
@@ -187,23 +184,17 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
/* setup the RTF parser */
RTFSetEditStream
(
info
->
parser
,(
EDITSTREAM
*
)
lParam
);
info
->
parser
->
rtfFormat
=
wParam
&
(
SF_TEXT
|
SF_RTF
);
info
->
parser
->
hwndEdit
=
hwnd
;
WriterInit
(
info
->
parser
);
RTFInit
(
info
->
parser
);
BeginFile
(
info
->
parser
);
/* do the parsing */
RTFRead
(
info
->
parser
);
RTFFlushOutputBuffer
(
info
->
parser
);
rtfBufferSize
=
RTFToBuffer
(
info
->
parser
,
NULL
,
0
);
info
->
rtfBuffer
=
HeapAlloc
(
RICHED32_hHeap
,
0
,
rtfBufferSize
*
sizeof
(
char
));
if
(
info
->
rtfBuffer
)
{
RTFToBuffer
(
info
->
parser
,
info
->
rtfBuffer
,
rtfBufferSize
);
CallWindowProcA
(
lpfnEditWndProc
,
hwnd
,
WM_SETTEXT
,
0
,
(
LPARAM
)
info
->
rtfBuffer
);
HeapFree
(
RICHED32_hHeap
,
0
,
info
->
rtfBuffer
);
}
else
WARN
(
"Not enough memory for a allocating rtfBuffer
\n
"
);
/* put the cursor at the top */
SendMessageA
(
hwnd
,
EM_SETSEL
,
0
,
0
);
return
0
;
...
...
dlls/richedit/rtf.h
View file @
f91e5825
...
...
@@ -1374,8 +1374,6 @@ struct RTFStyleElt
};
#include "charlist.h"
/*
* Return pointer to new element of type t, or NULL
* if no memory available.
...
...
@@ -1444,7 +1442,12 @@ struct _RTF_Info {
char
*
outputName
;
EDITSTREAM
editstream
;
CHARLIST
inputCharList
;
char
InputBuffer
[
0x1000
];
DWORD
dwInputSize
;
DWORD
dwInputUsed
;
/* edit window to output to */
HWND
hwndEdit
;
/*
* These arrays are used to map RTF input character values onto the standard
...
...
@@ -1493,8 +1496,8 @@ struct _RTF_Info {
char
*
outMap
[
rtfSC_MaxChar
];
CHARLIST
charlis
t
;
DWORD
dwOutputCoun
t
;
char
OutputBuffer
[
0x1000
];
};
...
...
@@ -1559,6 +1562,7 @@ void RTFSetCharSet( RTF_Info *, int);
void
RTFSetOpenLibFileProc
(
RTF_Info
*
,
FILE
*
(
*
)());
FILE
*
RTFOpenLibFile
(
RTF_Info
*
,
char
*
,
char
*
);
void
RTFFlushOutputBuffer
(
RTF_Info
*
info
);
void
RTFSetEditStream
(
RTF_Info
*
,
EDITSTREAM
*
es
);
#endif
dlls/richedit/text-writer.c
View file @
f91e5825
...
...
@@ -40,7 +40,6 @@
#include "rtf.h"
#include "rtf2text.h"
#include "charlist.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
richedit
);
...
...
@@ -53,42 +52,6 @@ static void PutStdChar (RTF_Info *info, int stdCode);
static
void
PutLitChar
(
RTF_Info
*
info
,
int
c
);
static
void
PutLitStr
(
RTF_Info
*
info
,
char
*
s
);
#if 0
static char *outMap[rtfSC_MaxChar];
static CHARLIST charlist = {0, NULL, NULL};
#endif
/*int RTFToBuffer(char* pBuffer, int nBufferSize); */
int
RTFToBuffer
(
RTF_Info
*
info
,
char
*
pBuffer
,
int
nBufferSize
)
{
/* check if the buffer is big enough to hold all characters */
/* we require one more for the '\0' */
TRACE
(
"
\n
"
);
if
(
nBufferSize
<
info
->
charlist
.
nCount
+
1
)
{
return
info
->
charlist
.
nCount
+
CHARLIST_CountChar
(
&
info
->
charlist
,
'\n'
)
+
1
;
}
while
(
info
->
charlist
.
nCount
)
{
*
pBuffer
=
CHARLIST_Dequeue
(
&
info
->
charlist
);
if
(
*
pBuffer
==
'\n'
)
{
*
pBuffer
=
'\r'
;
pBuffer
++
;
*
pBuffer
=
'\n'
;
}
pBuffer
++
;
}
*
pBuffer
=
'\0'
;
return
0
;
}
/*
* Initialize the writer.
*/
...
...
@@ -277,19 +240,30 @@ void PutStdChar (RTF_Info *info, int stdCode)
PutLitStr
(
info
,
oStr
);
}
void
PutLitChar
(
RTF_Info
*
info
,
int
c
)
{
CHARLIST_Enqueue
(
&
info
->
charlist
,
(
char
)
c
);
/* fputc (c, ostream); */
if
(
info
->
dwOutputCount
>=
(
sizeof
info
->
OutputBuffer
-
1
)
)
RTFFlushOutputBuffer
(
info
);
info
->
OutputBuffer
[
info
->
dwOutputCount
++
]
=
c
;
}
void
RTFFlushOutputBuffer
(
RTF_Info
*
info
)
{
info
->
OutputBuffer
[
info
->
dwOutputCount
]
=
0
;
SendMessageA
(
info
->
hwndEdit
,
EM_REPLACESEL
,
FALSE
,
(
LPARAM
)
info
->
OutputBuffer
);
info
->
dwOutputCount
=
0
;
}
static
void
PutLitStr
(
RTF_Info
*
info
,
char
*
s
)
static
void
PutLitStr
(
RTF_Info
*
info
,
char
*
str
)
{
for
(;
*
s
;
s
++
)
{
CHARLIST_Enqueue
(
&
info
->
charlist
,
*
s
);
}
/* fputs (s, ostream); */
int
len
=
strlen
(
str
);
if
(
(
len
+
info
->
dwOutputCount
+
1
)
>
sizeof
info
->
OutputBuffer
)
RTFFlushOutputBuffer
(
info
);
if
(
(
len
+
1
)
>=
sizeof
info
->
OutputBuffer
)
{
SendMessageA
(
info
->
hwndEdit
,
EM_REPLACESEL
,
FALSE
,
(
LPARAM
)
str
);
return
;
}
strcpy
(
&
info
->
OutputBuffer
[
info
->
dwOutputCount
],
str
);
info
->
dwOutputCount
+=
len
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment