Renamed Xedit -> Xed (avoid name clash with x11-apps's xedit)

This commit is contained in:
Clement Lefebvre
2016-02-04 09:20:42 +00:00
parent c8dd785ea8
commit 16eacdc3f4
487 changed files with 104410 additions and 104432 deletions

View File

@@ -1,7 +1,7 @@
AM_CPPFLAGS = -g -I$(top_srcdir) -I$(top_srcdir)/xedit $(XEDIT_DEBUG_FLAGS) $(XEDIT_CFLAGS)
AM_CPPFLAGS = -g -I$(top_srcdir) -I$(top_srcdir)/xed $(XED_DEBUG_FLAGS) $(XED_CFLAGS)
noinst_PROGRAMS = $(TEST_PROGS)
progs_ldadd = $(top_builddir)/xedit/libxedit.la
progs_ldadd = $(top_builddir)/xed/libxed.la
TEST_PROGS = smart-converter
smart_converter_SOURCES = smart-converter.c

View File

@@ -1,27 +1,27 @@
/*
* document-input-stream.c
* This file is part of xedit
* This file is part of xed
*
* Copyright (C) 2010 - Ignacio Casal Quinteiro
*
* xedit is free software; you can redistribute it and/or modify
* xed is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xedit is distributed in the hope that it will be useful,
* xed 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xedit; if not, write to the Free Software
* along with xed; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "xedit-document-input-stream.h"
#include "xed-document-input-stream.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
@@ -30,7 +30,7 @@
static void
test_consecutive_read (const gchar *inbuf,
const gchar *outbuf,
XeditDocumentNewlineType type,
XedDocumentNewlineType type,
gsize read_chunk_len)
{
GtkTextBuffer *buf;
@@ -45,7 +45,7 @@ test_consecutive_read (const gchar *inbuf,
gtk_text_buffer_set_text (buf, inbuf, -1);
b = g_malloc (200);
in = xedit_document_input_stream_new (buf, type);
in = xed_document_input_stream_new (buf, type);
outlen = strlen (outbuf);
n = 0;
@@ -78,63 +78,63 @@ static void
test_empty ()
{
/* empty file should not have a trailing newline */
test_consecutive_read ("", "", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 10);
test_consecutive_read ("", "", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 10);
}
static void
test_consecutive_cut_char ()
{
/* first \n is read then fo and then is added \r but not \n */
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 8);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 8);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 8);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 8);
}
static void
test_consecutive_big_read ()
{
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\rfo\rbar\r\rblah\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("\nfo\nbar\n\nblah", "\rfo\rbar\r\rblah\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\rfo\rbar\r\rblah\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("\nfo\nbar\n\nblah", "\rfo\rbar\r\rblah\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("\rfo\rbar\r\rblah\r", "\nfo\nbar\n\nblah\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\rfo\rbar\r\rblah", "\nfo\nbar\n\nblah\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\rfo\rbar\r\rblah\r", "\nfo\nbar\n\nblah\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\rfo\rbar\r\rblah", "\nfo\nbar\n\nblah\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah\r\n", "\nfo\nbar\n\nblah\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah", "\nfo\nbar\n\nblah\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah\r\n", "\nfo\nbar\n\nblah\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah", "\nfo\nbar\n\nblah\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 200);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 200);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 200);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 200);
}
static void
test_consecutive_middle_read ()
{
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\rfo\rbar\r\rblah\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("\nfo\nbar\n\nblah", "\rfo\rbar\r\rblah\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\rfo\rbar\r\rblah\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("\nfo\nbar\n\nblah", "\rfo\rbar\r\rblah\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("\rfo\rbar\r\rblah\r", "\nfo\nbar\n\nblah\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\rfo\rbar\r\rblah", "\nfo\nbar\n\nblah\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\rfo\rbar\r\rblah\r", "\nfo\nbar\n\nblah\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\rfo\rbar\r\rblah", "\nfo\nbar\n\nblah\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah\r\n", "\nfo\nbar\n\nblah\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah", "\nfo\nbar\n\nblah\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah\r\n", "\nfo\nbar\n\nblah\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\r\nfo\r\nbar\r\n\r\nblah", "\nfo\nbar\n\nblah\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 6);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, 6);
test_consecutive_read ("\nfo\nbar\n\nblah\n", "\r\nfo\r\nbar\r\n\r\nblah\r\n\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 6);
test_consecutive_read ("\nfo\nbar\n\nblah", "\r\nfo\r\nbar\r\n\r\nblah\r\n", XED_DOCUMENT_NEWLINE_TYPE_CR_LF, 6);
}
static void
test_consecutive_multibyte_cut ()
{
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\rhello\xe6\x96\x87\rworld\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("hello\rhello\xe6\x96\x87\rworld\r", "hello\rhello\xe6\x96\x87\rworld\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\nhello\xe6\x96\x87\nworld\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 6);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\rhello\xe6\x96\x87\rworld\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("hello\rhello\xe6\x96\x87\rworld\r", "hello\rhello\xe6\x96\x87\rworld\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 6);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\nhello\xe6\x96\x87\nworld\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 6);
}
static void
test_consecutive_multibyte_big_read ()
{
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\rhello\xe6\x96\x87\rworld\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("hello\rhello\xe6\x96\x87\rworld\r", "hello\rhello\xe6\x96\x87\rworld\r\r", XEDIT_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\nhello\xe6\x96\x87\nworld\n\n", XEDIT_DOCUMENT_NEWLINE_TYPE_LF, 200);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\rhello\xe6\x96\x87\rworld\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("hello\rhello\xe6\x96\x87\rworld\r", "hello\rhello\xe6\x96\x87\rworld\r\r", XED_DOCUMENT_NEWLINE_TYPE_CR, 200);
test_consecutive_read ("hello\nhello\xe6\x96\x87\nworld\n", "hello\nhello\xe6\x96\x87\nworld\n\n", XED_DOCUMENT_NEWLINE_TYPE_LF, 200);
}
int main (int argc,

View File

@@ -1,27 +1,27 @@
/*
* document-loader.c
* This file is part of xedit
* This file is part of xed
*
* Copyright (C) 2010 - Jesse van den Kieboom
*
* xedit is free software; you can redistribute it and/or modify
* xed is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xedit is distributed in the hope that it will be useful,
* xed 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xedit; if not, write to the Free Software
* along with xed; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "xedit-gio-document-loader.h"
#include "xedit-prefs-manager-app.h"
#include "xed-gio-document-loader.h"
#include "xed-prefs-manager-app.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
@@ -41,7 +41,7 @@ create_document (const gchar *filename,
const gchar *contents)
{
GError *error = NULL;
XeditDocument *document;
XedDocument *document;
gchar *uri;
if (!g_file_set_contents (filename, contents, -1, &error))
@@ -67,7 +67,7 @@ delete_document (GFile *location)
}
static void
on_document_loaded (XeditDocument *document,
on_document_loaded (XedDocument *document,
GError *error,
LoaderTestData *data)
{
@@ -89,7 +89,7 @@ on_document_loaded (XeditDocument *document,
if (data->newline_type != -1)
{
g_assert_cmpint (xedit_document_get_newline_type (document),
g_assert_cmpint (xed_document_get_newline_type (document),
==,
data->newline_type);
}
@@ -105,11 +105,11 @@ test_loader (const gchar *filename,
{
GFile *file;
gchar *uri;
XeditDocument *document;
XedDocument *document;
file = create_document (filename, contents);
document = xedit_document_new ();
document = xed_document_new ();
LoaderTestData *data = g_slice_new (LoaderTestData);
data->in_buffer = in_buffer;
@@ -125,7 +125,7 @@ test_loader (const gchar *filename,
uri = g_file_get_uri (file);
xedit_document_load (document, uri, xedit_encoding_get_utf8 (), 0, FALSE);
xed_document_load (document, uri, xed_encoding_get_utf8 (), 0, FALSE);
g_free (uri);
@@ -204,17 +204,17 @@ test_end_new_line_detection ()
test_loader ("document-loader.txt",
"hello world\n",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
XED_DOCUMENT_NEWLINE_TYPE_LF);
test_loader ("document-loader.txt",
"hello world\r\n",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF);
XED_DOCUMENT_NEWLINE_TYPE_CR_LF);
test_loader ("document-loader.txt",
"hello world\r",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR);
XED_DOCUMENT_NEWLINE_TYPE_CR);
}
static void
@@ -223,17 +223,17 @@ test_begin_new_line_detection ()
test_loader ("document-loader.txt",
"\nhello world",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
XED_DOCUMENT_NEWLINE_TYPE_LF);
test_loader ("document-loader.txt",
"\r\nhello world",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF);
XED_DOCUMENT_NEWLINE_TYPE_CR_LF);
test_loader ("document-loader.txt",
"\rhello world",
NULL,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR);
XED_DOCUMENT_NEWLINE_TYPE_CR);
}
int main (int argc,
@@ -241,7 +241,7 @@ int main (int argc,
{
g_test_init (&argc, &argv, NULL);
xedit_prefs_manager_app_init ();
xed_prefs_manager_app_init ();
g_test_add_func ("/document-loader/end-line-stripping", test_end_line_stripping);
g_test_add_func ("/document-loader/end-new-line-detection", test_end_new_line_detection);

View File

@@ -1,28 +1,28 @@
/*
* document-output-stream.c
* This file is part of xedit
* This file is part of xed
*
* Copyright (C) 2010 - Ignacio Casal Quinteiro
*
* xedit is free software; you can redistribute it and/or modify
* xed is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xedit is distributed in the hope that it will be useful,
* xed 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xedit; if not, write to the Free Software
* along with xed; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "xedit-document-output-stream.h"
#include "xedit-prefs-manager-app.h"
#include "xed-document-output-stream.h"
#include "xed-prefs-manager-app.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
@@ -32,18 +32,18 @@ static void
test_consecutive_write (const gchar *inbuf,
const gchar *outbuf,
gsize write_chunk_len,
XeditDocumentNewlineType newline_type)
XedDocumentNewlineType newline_type)
{
XeditDocument *doc;
XedDocument *doc;
GOutputStream *out;
gsize len;
gssize n, w;
GError *err = NULL;
gchar *b;
XeditDocumentNewlineType type;
XedDocumentNewlineType type;
doc = xedit_document_new ();
out = xedit_document_output_stream_new (doc);
doc = xed_document_new ();
out = xed_document_output_stream_new (doc);
n = 0;
@@ -65,7 +65,7 @@ test_consecutive_write (const gchar *inbuf,
g_assert_cmpstr (inbuf, ==, b);
g_free (b);
type = xedit_document_output_stream_detect_newline_type (XEDIT_DOCUMENT_OUTPUT_STREAM (out));
type = xed_document_output_stream_detect_newline_type (XED_DOCUMENT_OUTPUT_STREAM (out));
g_assert (type == newline_type);
g_output_stream_close (out, NULL, &err);
@@ -85,39 +85,39 @@ test_consecutive_write (const gchar *inbuf,
static void
test_empty ()
{
test_consecutive_write ("", "", 10, XEDIT_DOCUMENT_NEWLINE_TYPE_DEFAULT);
test_consecutive_write ("\r\n", "", 10, XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF);
test_consecutive_write ("\r", "", 10, XEDIT_DOCUMENT_NEWLINE_TYPE_CR);
test_consecutive_write ("\n", "", 10, XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
test_consecutive_write ("", "", 10, XED_DOCUMENT_NEWLINE_TYPE_DEFAULT);
test_consecutive_write ("\r\n", "", 10, XED_DOCUMENT_NEWLINE_TYPE_CR_LF);
test_consecutive_write ("\r", "", 10, XED_DOCUMENT_NEWLINE_TYPE_CR);
test_consecutive_write ("\n", "", 10, XED_DOCUMENT_NEWLINE_TYPE_LF);
}
static void
test_consecutive ()
{
test_consecutive_write ("hello\nhow\nare\nyou", "hello\nhow\nare\nyou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
XED_DOCUMENT_NEWLINE_TYPE_LF);
test_consecutive_write ("hello\rhow\rare\ryou", "hello\rhow\rare\ryou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR);
XED_DOCUMENT_NEWLINE_TYPE_CR);
test_consecutive_write ("hello\r\nhow\r\nare\r\nyou", "hello\r\nhow\r\nare\r\nyou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF);
XED_DOCUMENT_NEWLINE_TYPE_CR_LF);
}
static void
test_consecutive_tnewline ()
{
test_consecutive_write ("hello\nhow\nare\nyou\n", "hello\nhow\nare\nyou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
XED_DOCUMENT_NEWLINE_TYPE_LF);
test_consecutive_write ("hello\rhow\rare\ryou\r", "hello\rhow\rare\ryou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR);
XED_DOCUMENT_NEWLINE_TYPE_CR);
test_consecutive_write ("hello\r\nhow\r\nare\r\nyou\r\n", "hello\r\nhow\r\nare\r\nyou", 3,
XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF);
XED_DOCUMENT_NEWLINE_TYPE_CR_LF);
}
static void
test_big_char ()
{
test_consecutive_write ("\343\203\200\343\203\200", "\343\203\200\343\203\200", 2,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF);
XED_DOCUMENT_NEWLINE_TYPE_LF);
}
int main (int argc,
@@ -125,7 +125,7 @@ int main (int argc,
{
g_test_init (&argc, &argv, NULL);
xedit_prefs_manager_app_init ();
xed_prefs_manager_app_init ();
g_test_add_func ("/document-output-stream/empty", test_empty);

View File

@@ -1,27 +1,27 @@
/*
* document-saver.c
* This file is part of xedit
* This file is part of xed
*
* Copyright (C) 2010 - Jesse van den Kieboom
*
* xedit is free software; you can redistribute it and/or modify
* xed is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xedit is distributed in the hope that it will be useful,
* xed 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xedit; if not, write to the Free Software
* along with xed; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "xedit-gio-document-loader.h"
#include "xedit-prefs-manager-app.h"
#include "xed-gio-document-loader.h"
#include "xed-prefs-manager-app.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
@@ -29,19 +29,19 @@
#include <string.h>
#include <sys/stat.h>
#define DEFAULT_LOCAL_URI "/tmp/xedit-document-saver-test.txt"
#define DEFAULT_REMOTE_URI "sftp://localhost/tmp/xedit-document-saver-test.txt"
#define DEFAULT_LOCAL_URI "/tmp/xed-document-saver-test.txt"
#define DEFAULT_REMOTE_URI "sftp://localhost/tmp/xed-document-saver-test.txt"
#define DEFAULT_CONTENT "hello world!"
#define DEFAULT_CONTENT_RESULT "hello world!\n"
#define UNOWNED_LOCAL_DIRECTORY "/tmp/xedit-document-saver-unowned"
#define UNOWNED_LOCAL_URI "/tmp/xedit-document-saver-unowned/xedit-document-saver-test.txt"
#define UNOWNED_LOCAL_DIRECTORY "/tmp/xed-document-saver-unowned"
#define UNOWNED_LOCAL_URI "/tmp/xed-document-saver-unowned/xed-document-saver-test.txt"
#define UNOWNED_REMOTE_DIRECTORY "sftp://localhost/tmp/xedit-document-saver-unowned"
#define UNOWNED_REMOTE_URI "sftp://localhost/tmp/xedit-document-saver-unowned/xedit-document-saver-test.txt"
#define UNOWNED_REMOTE_DIRECTORY "sftp://localhost/tmp/xed-document-saver-unowned"
#define UNOWNED_REMOTE_URI "sftp://localhost/tmp/xed-document-saver-unowned/xed-document-saver-test.txt"
#define UNOWNED_GROUP_LOCAL_URI "/tmp/xedit-document-saver-unowned-group.txt"
#define UNOWNED_GROUP_REMOTE_URI "sftp://localhost/tmp/xedit-document-saver-unowned-group.txt"
#define UNOWNED_GROUP_LOCAL_URI "/tmp/xed-document-saver-unowned-group.txt"
#define UNOWNED_GROUP_REMOTE_URI "sftp://localhost/tmp/xed-document-saver-unowned-group.txt"
static gboolean test_completed;
static gboolean mount_completed;
@@ -78,17 +78,17 @@ saver_test_data_free (SaverTestData *data)
g_slice_free (SaverTestData, data);
}
static XeditDocument *
static XedDocument *
create_document (const gchar *contents)
{
XeditDocument *document = xedit_document_new ();
XedDocument *document = xed_document_new ();
gtk_text_buffer_set_text (GTK_TEXT_BUFFER (document), contents, -1);
return document;
}
static void
complete_test_error (XeditDocument *document,
complete_test_error (XedDocument *document,
GError *error,
SaverTestData *data)
{
@@ -121,7 +121,7 @@ read_file (const gchar *uri)
}
static void
complete_test (XeditDocument *document,
complete_test (XedDocument *document,
GError *error,
SaverTestData *data)
{
@@ -191,18 +191,18 @@ ensure_mounted (GFile *file)
static void
test_saver (const gchar *filename_or_uri,
const gchar *contents,
XeditDocumentNewlineType newline_type,
XeditDocumentSaveFlags save_flags,
XedDocumentNewlineType newline_type,
XedDocumentSaveFlags save_flags,
GCallback saved_callback,
SaverTestData *data)
{
GFile *file;
gchar *uri;
XeditDocument *document;
XedDocument *document;
gboolean existed;
document = create_document (contents);
xedit_document_set_newline_type (document, newline_type);
xed_document_set_newline_type (document, newline_type);
g_signal_connect (document, "saved", G_CALLBACK (complete_test_error), data);
@@ -221,7 +221,7 @@ test_saver (const gchar *filename_or_uri,
ensure_mounted (file);
xedit_document_save_as (document, uri, xedit_encoding_get_utf8 (), save_flags);
xed_document_save_as (document, uri, xed_encoding_get_utf8 (), save_flags);
while (!test_completed)
{
@@ -241,45 +241,45 @@ test_saver (const gchar *filename_or_uri,
typedef struct
{
XeditDocumentNewlineType type;
XedDocumentNewlineType type;
const gchar *text;
const gchar *result;
} NewLineTestData;
static NewLineTestData newline_test_data[] = {
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld", "\nhello\nworld\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld\n", "\nhello\nworld\n\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld\n\n", "\nhello\nworld\n\n\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\r\nhello\r\nworld", "\nhello\nworld\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\r\nhello\r\nworld\r\n", "\nhello\nworld\n\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\rhello\rworld", "\nhello\nworld\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\rhello\rworld\r", "\nhello\nworld\n\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\r\nworld", "\nhello\nworld\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\r\nworld\r", "\nhello\nworld\n\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld", "\nhello\nworld\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld\n", "\nhello\nworld\n\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\nworld\n\n", "\nhello\nworld\n\n\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\r\nhello\r\nworld", "\nhello\nworld\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\r\nhello\r\nworld\r\n", "\nhello\nworld\n\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\rhello\rworld", "\nhello\nworld\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\rhello\rworld\r", "\nhello\nworld\n\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\r\nworld", "\nhello\nworld\n"},
{XED_DOCUMENT_NEWLINE_TYPE_LF, "\nhello\r\nworld\r", "\nhello\nworld\n\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld", "\r\nhello\r\nworld\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld\n", "\r\nhello\r\nworld\r\n\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld\n\n", "\r\nhello\r\nworld\r\n\r\n\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\r\nhello\r\nworld", "\r\nhello\r\nworld\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\r\nhello\r\nworld\r\n", "\r\nhello\r\nworld\r\n\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\rhello\rworld", "\r\nhello\r\nworld\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\rhello\rworld\r", "\r\nhello\r\nworld\r\n\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\r\nworld", "\r\nhello\r\nworld\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\r\nworld\r", "\r\nhello\r\nworld\r\n\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld", "\r\nhello\r\nworld\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld\n", "\r\nhello\r\nworld\r\n\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\nworld\n\n", "\r\nhello\r\nworld\r\n\r\n\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\r\nhello\r\nworld", "\r\nhello\r\nworld\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\r\nhello\r\nworld\r\n", "\r\nhello\r\nworld\r\n\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\rhello\rworld", "\r\nhello\r\nworld\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\rhello\rworld\r", "\r\nhello\r\nworld\r\n\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\r\nworld", "\r\nhello\r\nworld\r\n"},
{XED_DOCUMENT_NEWLINE_TYPE_CR_LF, "\nhello\r\nworld\r", "\r\nhello\r\nworld\r\n\r\n"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld", "\rhello\rworld\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld\n", "\rhello\rworld\r\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld\n\n", "\rhello\rworld\r\r\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\r\nhello\r\nworld", "\rhello\rworld\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\r\nhello\r\nworld\r\n", "\rhello\rworld\r\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\rhello\rworld", "\rhello\rworld\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\rhello\rworld\r", "\rhello\rworld\r\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\r\nworld", "\rhello\rworld\r"},
{XEDIT_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\r\nworld\r", "\rhello\rworld\r\r"}
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld", "\rhello\rworld\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld\n", "\rhello\rworld\r\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\nworld\n\n", "\rhello\rworld\r\r\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\r\nhello\r\nworld", "\rhello\rworld\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\r\nhello\r\nworld\r\n", "\rhello\rworld\r\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\rhello\rworld", "\rhello\rworld\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\rhello\rworld\r", "\rhello\rworld\r\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\r\nworld", "\rhello\rworld\r"},
{XED_DOCUMENT_NEWLINE_TYPE_CR, "\nhello\r\nworld\r", "\rhello\rworld\r\r"}
};
static void
test_new_line (const gchar *filename, XeditDocumentSaveFlags save_flags)
test_new_line (const gchar *filename, XedDocumentSaveFlags save_flags)
{
gint i;
gint num = sizeof (newline_test_data) / sizeof (NewLineTestData);
@@ -308,21 +308,21 @@ test_local ()
{
test_saver (DEFAULT_LOCAL_URI,
"hello world",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_LOCAL_URI, "hello world\n", NULL));
test_saver (DEFAULT_LOCAL_URI,
"hello world\r\n",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_LOCAL_URI, "hello world\n\n", NULL));
test_saver (DEFAULT_LOCAL_URI,
"hello world\n",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_LOCAL_URI, "hello world\n\n", NULL));
@@ -339,21 +339,21 @@ test_remote ()
{
test_saver (DEFAULT_REMOTE_URI,
"hello world",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_REMOTE_URI, "hello world\n", NULL));
test_saver (DEFAULT_REMOTE_URI,
"hello world\r\n",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_REMOTE_URI, "hello world\n\n", NULL));
test_saver (DEFAULT_REMOTE_URI,
"hello world\n",
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (DEFAULT_REMOTE_URI, "hello world\n\n", NULL));
@@ -382,12 +382,12 @@ check_permissions (GFile *file,
}
static void
check_permissions_saved (XeditDocument *document,
check_permissions_saved (XedDocument *document,
GError *error,
SaverTestData *data)
{
guint permissions = (guint)GPOINTER_TO_INT (data->data);
GFile *file = xedit_document_get_location (document);
GFile *file = xed_document_get_location (document);
check_permissions (file, permissions);
@@ -435,7 +435,7 @@ test_permissions (const gchar *uri,
test_saver (uri,
DEFAULT_CONTENT,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
G_CALLBACK (check_permissions_saved),
saver_test_data_new (uri,
@@ -460,7 +460,7 @@ test_local_unowned_directory ()
{
test_saver (UNOWNED_LOCAL_URI,
DEFAULT_CONTENT,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (UNOWNED_LOCAL_URI,
@@ -473,7 +473,7 @@ test_remote_unowned_directory ()
{
test_saver (UNOWNED_REMOTE_URI,
DEFAULT_CONTENT,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
NULL,
saver_test_data_new (UNOWNED_REMOTE_URI,
@@ -491,7 +491,7 @@ test_remote_permissions ()
}
static void
test_unowned_group_permissions (XeditDocument *document,
test_unowned_group_permissions (XedDocument *document,
GError *error,
SaverTestData *data)
{
@@ -525,7 +525,7 @@ test_unowned_group (const gchar *uri)
{
test_saver (uri,
DEFAULT_CONTENT,
XEDIT_DOCUMENT_NEWLINE_TYPE_LF,
XED_DOCUMENT_NEWLINE_TYPE_LF,
0,
G_CALLBACK (test_unowned_group_permissions),
saver_test_data_new (uri,
@@ -684,7 +684,7 @@ int main (int argc,
g_test_init (&argc, &argv, NULL);
xedit_prefs_manager_app_init ();
xed_prefs_manager_app_init ();
g_printf ("\n***\n");
have_unowned = check_unowned_directory ();

View File

@@ -3,10 +3,10 @@
# This script is used to setup some special directory structures, permissions
# for the saver test
UNOWNED_DIRECTORY="/tmp/xedit-document-saver-unowned"
UNOWNED_FILE="/tmp/xedit-document-saver-unowned/xedit-document-saver-test.txt"
UNOWNED_DIRECTORY="/tmp/xed-document-saver-unowned"
UNOWNED_FILE="/tmp/xed-document-saver-unowned/xed-document-saver-test.txt"
UNOWNED_GROUP="/tmp/xedit-document-saver-unowned-group.txt"
UNOWNED_GROUP="/tmp/xed-document-saver-unowned-group.txt"
if [ -f "$UNOWNED_FILE" ]; then
sudo rm "$UNOWNED_FILE"

View File

@@ -1,28 +1,28 @@
/*
* smart-converter.c
* This file is part of xedit
* This file is part of xed
*
* Copyright (C) 2009 - Ignacio Casal Quinteiro
*
* xedit is free software; you can redistribute it and/or modify
* xed is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xedit is distributed in the hope that it will be useful,
* xed 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xedit; if not, write to the Free Software
* along with xed; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "xedit-smart-charset-converter.h"
#include "xedit-encodings.h"
#include "xed-smart-charset-converter.h"
#include "xed-encodings.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib/gprintf.h>
@@ -47,8 +47,8 @@ print_hex (gchar *ptr, gint len)
static gchar *
get_encoded_text (const gchar *text,
gsize nread,
const XeditEncoding *to,
const XeditEncoding *from,
const XedEncoding *to,
const XedEncoding *from,
gsize *bytes_written_aux,
gboolean care_about_error)
{
@@ -59,8 +59,8 @@ get_encoded_text (const gchar *text,
GConverterResult res;
GError *err;
converter = g_charset_converter_new (xedit_encoding_get_charset (to),
xedit_encoding_get_charset (from),
converter = g_charset_converter_new (xed_encoding_get_charset (to),
xed_encoding_get_charset (from),
NULL);
out = g_malloc (200);
@@ -126,9 +126,9 @@ get_all_encodings ()
while (TRUE)
{
const XeditEncoding *enc;
const XedEncoding *enc;
enc = xedit_encoding_get_from_index (i);
enc = xed_encoding_get_from_index (i);
if (enc == NULL)
break;
@@ -145,9 +145,9 @@ do_test (const gchar *test_in,
const gchar *enc,
GSList *encodings,
gsize nread,
const XeditEncoding **guessed)
const XedEncoding **guessed)
{
XeditSmartCharsetConverter *converter;
XedSmartCharsetConverter *converter;
gchar *out, *out_aux;
gsize bytes_read, bytes_read_aux;
gsize bytes_written, bytes_written_aux;
@@ -157,10 +157,10 @@ do_test (const gchar *test_in,
if (enc != NULL)
{
encodings = NULL;
encodings = g_slist_prepend (encodings, (gpointer)xedit_encoding_get_from_charset (enc));
encodings = g_slist_prepend (encodings, (gpointer)xed_encoding_get_from_charset (enc));
}
converter = xedit_smart_charset_converter_new (encodings);
converter = xed_smart_charset_converter_new (encodings);
out = g_malloc (200);
out_aux = g_malloc (200);
@@ -189,7 +189,7 @@ do_test (const gchar *test_in,
out[bytes_written_aux] = '\0';
if (guessed != NULL)
*guessed = xedit_smart_charset_converter_get_guessed (converter);
*guessed = xed_smart_charset_converter_get_guessed (converter);
return out;
}
@@ -201,7 +201,7 @@ do_test_roundtrip (const char *str, const char *charset)
gchar *buf, *p;
GInputStream *in, *tmp;
GCharsetConverter *c1;
XeditSmartCharsetConverter *c2;
XedSmartCharsetConverter *c2;
gsize n, tot;
GError *err;
GSList *enc = NULL;
@@ -218,8 +218,8 @@ do_test_roundtrip (const char *str, const char *charset)
g_object_unref (tmp);
g_object_unref (c1);
enc = g_slist_prepend (enc, (gpointer)xedit_encoding_get_from_charset (charset));
c2 = xedit_smart_charset_converter_new (enc);
enc = g_slist_prepend (enc, (gpointer)xed_encoding_get_from_charset (charset));
c2 = xed_smart_charset_converter_new (enc);
g_slist_free (enc);
tmp = in;
@@ -281,7 +281,7 @@ test_xxx_xxx ()
are done ok */
for (l = encs; l != NULL; l = g_slist_next (l))
{
do_test_roundtrip (TEXT_TO_CONVERT, xedit_encoding_get_charset ((const XeditEncoding *)l->data));
do_test_roundtrip (TEXT_TO_CONVERT, xed_encoding_get_charset ((const XedEncoding *)l->data));
}
g_slist_free (encs);
@@ -290,7 +290,7 @@ test_xxx_xxx ()
static void
test_empty ()
{
const XeditEncoding *guessed;
const XedEncoding *guessed;
gchar *out;
GSList *encodings = NULL;
@@ -298,14 +298,14 @@ test_empty ()
utf-8. In this case, the smart converter cannot determine the right
encoding (because there is no input), but should still default to
utf-8 for the detection */
encodings = g_slist_prepend (encodings, (gpointer)xedit_encoding_get_from_charset ("UTF-16"));
encodings = g_slist_prepend (encodings, (gpointer)xedit_encoding_get_from_charset ("ISO-8859-15"));
encodings = g_slist_prepend (encodings, (gpointer)xed_encoding_get_from_charset ("UTF-16"));
encodings = g_slist_prepend (encodings, (gpointer)xed_encoding_get_from_charset ("ISO-8859-15"));
out = do_test ("", NULL, encodings, 0, &guessed);
g_assert_cmpstr (out, ==, "");
g_assert (guessed == xedit_encoding_get_utf8 ());
g_assert (guessed == xed_encoding_get_utf8 ());
}
static void
@@ -314,29 +314,29 @@ test_guessed ()
GSList *encs = NULL;
gchar *aux, *aux2, *fail;
gsize aux_len, fail_len;
const XeditEncoding *guessed;
const XedEncoding *guessed;
aux = get_encoded_text (TEXT_TO_GUESS, -1,
xedit_encoding_get_from_charset ("UTF-16"),
xedit_encoding_get_from_charset ("UTF-8"),
xed_encoding_get_from_charset ("UTF-16"),
xed_encoding_get_from_charset ("UTF-8"),
&aux_len,
TRUE);
fail = get_encoded_text (aux, aux_len,
xedit_encoding_get_from_charset ("UTF-8"),
xedit_encoding_get_from_charset ("ISO-8859-15"),
xed_encoding_get_from_charset ("UTF-8"),
xed_encoding_get_from_charset ("ISO-8859-15"),
&fail_len,
FALSE);
g_assert (fail == NULL);
/* ISO-8859-15 should fail */
encs = g_slist_append (encs, (gpointer)xedit_encoding_get_from_charset ("ISO-8859-15"));
encs = g_slist_append (encs, (gpointer)xedit_encoding_get_from_charset ("UTF-16"));
encs = g_slist_append (encs, (gpointer)xed_encoding_get_from_charset ("ISO-8859-15"));
encs = g_slist_append (encs, (gpointer)xed_encoding_get_from_charset ("UTF-16"));
aux2 = do_test (aux, NULL, encs, aux_len, &guessed);
g_assert (guessed == xedit_encoding_get_from_charset ("UTF-16"));
g_assert (guessed == xed_encoding_get_from_charset ("UTF-16"));
}
int main (int argc,