I updated the patch for ed 1.4.
Could you please find the attachment.
Thanks,
fujiwara
(07/23/09 08:11), Antonio Diaz Diaz-san wrote:
Takao Fujiwara wrote:
I checked out CVS HEAD and the version is 0.2
I work on a computer without internet connection, so I do not use CVS. I
didn't know version 0.2 was available through CVS at Savannah, but I'll
disable it because it is clearly obsolete.
You can find the latest stable version of ed here
http://ftp.gnu.org/gnu/ed/
Ed is not a multi-byte editor. Are you sure your patch does not break
other encodings?
Yes, the algorithm works for all encodings.
OK. I'll check it as soon as I can after you send the updated patch.
Regards,
Antonio.
--- ed-1.4/io.c.orig 2009-06-12 20:13:06.000000000 +0900
+++ ed-1.4/io.c 2009-07-23 10:33:06.000000000 +0900
@@ -20,6 +20,8 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
+#include <wchar.h>
#include "ed.h"
@@ -236,8 +238,13 @@ int read_file( const char *filename, con
{
FILE *fp;
long size;
+ mbstate_t mbs;
+ int is_bang = 0;
- if( *filename == '!' ) fp = popen( filename + 1, "r" );
+ memset (&mbs, 0, sizeof (mbs));
+ is_bang = ((mbrlen (filename, MB_CUR_MAX, &mbs) == 1) &&
+ (*filename == '!')) ? 1 : 0;
+ if( is_bang ) fp = popen( filename + 1, "r" );
else fp = fopen( strip_escapes( filename ), "r" );
if( !fp )
{
@@ -246,7 +253,7 @@ int read_file( const char *filename, con
return -1;
}
if( ( size = read_stream( fp, addr ) ) < 0 ) return -1;
- if( ( (*filename == '!' ) ? pclose( fp ) : fclose( fp ) ) < 0 )
+ if( ( ( is_bang ) ? pclose( fp ) : fclose( fp ) ) < 0 )
{
show_strerror( filename, errno );
set_error_msg( "Cannot close input file" );
@@ -291,8 +298,13 @@ int write_file( const char * const filen
{
FILE *fp;
long size;
+ mbstate_t mbs;
+ int is_bang = 0;
- if( *filename == '!' ) fp = popen( filename + 1, "w" );
+ memset (&mbs, 0, sizeof (mbs));
+ is_bang = ((mbrlen (filename, MB_CUR_MAX, &mbs) == 1) &&
+ (*filename == '!')) ? 1 : 0;
+ if( is_bang ) fp = popen( filename + 1, "w" );
else fp = fopen( strip_escapes( filename ), mode );
if( !fp )
{
@@ -301,7 +313,7 @@ int write_file( const char * const filen
return -1;
}
if( ( size = write_stream( fp, from, to ) ) < 0 ) return -1;
- if( ( (*filename == '!' ) ? pclose( fp ) : fclose( fp ) ) < 0 )
+ if( ( ( is_bang ) ? pclose( fp ) : fclose( fp ) ) < 0 )
{
show_strerror( filename, errno );
set_error_msg( "Cannot close output file" );
--- ed-1.4/regex.c.orig 2009-06-12 20:15:28.000000000 +0900
+++ ed-1.4/regex.c 2009-07-23 10:33:06.000000000 +0900
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <wchar.h>
#include "ed.h"
@@ -87,9 +88,18 @@ static char *extract_pattern( const char
static int bufsz = 0;
const char *nd = *ibufpp;
int len;
+ mbstate_t mbs;
while( *nd != delimiter && *nd != '\n' )
{
+ memset (&mbs, 0, sizeof (mbs));
+ len = mbrlen (nd, MB_CUR_MAX, &mbs);
+ if (len > 1)
+ {
+ nd += len;
+ continue;
+ }
+
if( *nd == '[' )
{
nd = parse_char_class( ++nd );
--- ed-1.4/signal.c.orig 2009-06-12 21:25:39.000000000 +0900
+++ ed-1.4/signal.c 2009-07-23 10:38:14.000000000 +0900
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#include <wchar.h>
#include "ed.h"
@@ -248,12 +249,28 @@ const char *strip_escapes( const char *s
static char *buf = 0;
static int bufsz = 0;
const int len = strlen( s );
+ int char_len;
+ mbstate_t mbs;
int i = 0;
if( !resize_buffer( &buf, &bufsz, len + 1 ) ) return 0;
/* assert: no trailing escape */
- while( ( buf[i++] = ( (*s == '\\' ) ? *++s : *s ) ) )
- s++;
+ while( *s )
+ {
+ memset (&mbs, 0, sizeof (mbs));
+ char_len = mbrlen (s, MB_CUR_MAX, &mbs);
+ if (char_len > 1)
+ {
+ while (char_len > 0)
+ {
+ buf[i++] = *s++;
+ char_len--;
+ }
+ continue;
+ }
+ buf[i++] = ( (*s == '\\' ) ? *++s : *s );
+ s++;
+ }
return buf;
}
_______________________________________________
bug-ed mailing list
bug-ed@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-ed