2010-11-18 02:35:33 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2011-03-05 21:00:41 +01:00
|
|
|
#include <stdarg.h>
|
2010-11-18 03:15:32 +01:00
|
|
|
#include <string.h>
|
2010-11-29 14:58:56 +01:00
|
|
|
#include <stdio.h>
|
2010-11-18 02:35:33 +01:00
|
|
|
#include <unistd.h>
|
2010-11-29 14:58:56 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2012-02-09 12:31:39 +01:00
|
|
|
#include <math.h>
|
2012-04-21 04:59:58 +02:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <girara/session.h>
|
2012-04-22 10:04:46 +02:00
|
|
|
#include <girara/utils.h>
|
2012-05-29 14:22:04 +02:00
|
|
|
#include <girara/settings.h>
|
2012-04-22 10:04:46 +02:00
|
|
|
#include <glib/gi18n.h>
|
2010-11-18 02:35:33 +01:00
|
|
|
|
2012-05-28 12:43:22 +02:00
|
|
|
#include "links.h"
|
2010-11-18 02:35:33 +01:00
|
|
|
#include "utils.h"
|
2011-02-10 04:33:28 +01:00
|
|
|
#include "zathura.h"
|
2012-03-27 21:59:35 +02:00
|
|
|
#include "internal.h"
|
2011-04-18 18:29:50 +02:00
|
|
|
#include "document.h"
|
2012-03-26 14:44:56 +02:00
|
|
|
#include "page.h"
|
2012-03-27 13:30:04 +02:00
|
|
|
#include "plugin.h"
|
2010-11-18 02:35:33 +01:00
|
|
|
|
2011-10-23 17:01:15 +02:00
|
|
|
#include <girara/datastructures.h>
|
|
|
|
|
2010-11-29 14:58:56 +01:00
|
|
|
#define BLOCK_SIZE 64
|
|
|
|
|
2010-11-18 02:35:33 +01:00
|
|
|
const char*
|
|
|
|
file_get_extension(const char* path)
|
|
|
|
{
|
2013-05-04 19:33:14 +02:00
|
|
|
if (path == NULL) {
|
2010-11-18 03:15:32 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-04 19:33:14 +02:00
|
|
|
const char* res = strrchr(path, '.');
|
|
|
|
if (res == NULL) {
|
2010-11-18 03:15:32 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-04 19:33:14 +02:00
|
|
|
return res + 1;
|
2010-11-18 02:35:33 +01:00
|
|
|
}
|
2010-11-29 14:58:56 +01:00
|
|
|
|
2011-05-25 00:54:16 +02:00
|
|
|
bool
|
|
|
|
file_valid_extension(zathura_t* zathura, const char* path)
|
|
|
|
{
|
2012-05-21 23:16:29 +02:00
|
|
|
if (zathura == NULL || path == NULL || zathura->plugins.manager == NULL) {
|
2011-05-25 00:54:16 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-29 15:23:13 +02:00
|
|
|
const gchar* content_type = g_content_type_guess(path, NULL, 0, NULL);
|
|
|
|
if (content_type == NULL) {
|
2011-05-26 12:05:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-03 09:02:45 +02:00
|
|
|
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
|
2011-09-29 18:08:37 +02:00
|
|
|
g_free((void*)content_type);
|
2012-04-01 18:32:16 +02:00
|
|
|
|
|
|
|
return (plugin == NULL) ? false : true;
|
2011-05-25 00:54:16 +02:00
|
|
|
}
|
|
|
|
|
2010-11-29 14:58:56 +01:00
|
|
|
bool
|
|
|
|
execute_command(char* const argv[], char** output)
|
|
|
|
{
|
2011-02-09 12:29:09 +01:00
|
|
|
if (!output) {
|
2010-11-29 14:58:56 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int p[2];
|
2011-02-09 12:29:09 +01:00
|
|
|
if (pipe(p)) {
|
2010-11-29 14:58:56 +01:00
|
|
|
return -1;
|
2010-12-26 01:12:20 +01:00
|
|
|
}
|
2010-11-29 14:58:56 +01:00
|
|
|
|
|
|
|
pid_t pid = fork();
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (pid == -1) { // failure
|
2010-11-29 14:58:56 +01:00
|
|
|
return false;
|
2011-02-09 12:29:09 +01:00
|
|
|
} else if (pid == 0) { // child
|
2010-11-29 14:58:56 +01:00
|
|
|
dup2(p[1], 1);
|
|
|
|
close(p[0]);
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (execvp(argv[0], argv) == -1) {
|
2010-11-29 14:58:56 +01:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-26 01:12:20 +01:00
|
|
|
} else { // parent
|
2010-11-29 14:58:56 +01:00
|
|
|
dup2(p[0], 0);
|
|
|
|
close(p[1]);
|
|
|
|
|
|
|
|
/* read output */
|
|
|
|
unsigned int bc = BLOCK_SIZE;
|
|
|
|
unsigned int i = 0;
|
|
|
|
char* buffer = malloc(sizeof(char) * bc);
|
|
|
|
*output = NULL;
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (!buffer) {
|
2010-11-29 14:58:56 +01:00
|
|
|
close(p[0]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
char c;
|
2011-02-09 12:29:09 +01:00
|
|
|
while (1 == read(p[0], &c, 1)) {
|
2010-11-29 14:58:56 +01:00
|
|
|
buffer[i++] = c;
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (i == bc) {
|
2010-11-29 14:58:56 +01:00
|
|
|
bc += BLOCK_SIZE;
|
|
|
|
char* tmp = realloc(buffer, sizeof(char) * bc);
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (!tmp) {
|
2010-11-29 14:58:56 +01:00
|
|
|
free(buffer);
|
|
|
|
close(p[0]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char* tmp = realloc(buffer, sizeof(char) * (bc + 1));
|
2011-02-09 12:29:09 +01:00
|
|
|
if (!tmp) {
|
2010-11-29 14:58:56 +01:00
|
|
|
free(buffer);
|
|
|
|
close(p[0]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = tmp;
|
|
|
|
buffer[i] = '\0';
|
|
|
|
|
|
|
|
*output = buffer;
|
|
|
|
|
|
|
|
/* wait for child to terminate */
|
|
|
|
waitpid(pid, NULL, 0);
|
|
|
|
close(p[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-12-28 09:47:09 +01:00
|
|
|
|
2011-02-10 04:33:28 +01:00
|
|
|
void
|
2011-09-29 16:50:52 +02:00
|
|
|
document_index_build(GtkTreeModel* model, GtkTreeIter* parent,
|
2012-10-09 01:12:18 +02:00
|
|
|
girara_tree_node_t* tree)
|
2011-02-10 04:33:28 +01:00
|
|
|
{
|
2011-09-29 16:50:52 +02:00
|
|
|
girara_list_t* list = girara_node_get_children(tree);
|
|
|
|
GIRARA_LIST_FOREACH(list, girara_tree_node_t*, iter, node)
|
2012-10-09 01:12:18 +02:00
|
|
|
zathura_index_element_t* index_element = (zathura_index_element_t*)girara_node_get_data(node);
|
2011-02-10 04:33:28 +01:00
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
zathura_link_type_t type = zathura_link_get_type(index_element->link);
|
|
|
|
zathura_link_target_t target = zathura_link_get_target(index_element->link);
|
2012-04-22 10:04:46 +02:00
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
gchar* description = NULL;
|
|
|
|
if (type == ZATHURA_LINK_GOTO_DEST) {
|
|
|
|
description = g_strdup_printf("Page %d", target.page_number + 1);
|
|
|
|
} else {
|
|
|
|
description = g_strdup(target.value);
|
|
|
|
}
|
2011-09-29 17:28:09 +02:00
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
GtkTreeIter tree_iter;
|
|
|
|
gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent);
|
|
|
|
gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, index_element->title, 1, description, 2, index_element, -1);
|
|
|
|
g_object_weak_ref(G_OBJECT(model), (GWeakNotify) zathura_index_element_free, index_element);
|
|
|
|
g_free(description);
|
2011-09-29 16:50:52 +02:00
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
if (girara_node_get_num_children(node) > 0) {
|
|
|
|
document_index_build(model, &tree_iter, node);
|
|
|
|
}
|
2011-09-29 16:50:52 +02:00
|
|
|
|
2011-10-17 11:16:14 +02:00
|
|
|
GIRARA_LIST_FOREACH_END(list, gchar*, iter, name);
|
2011-02-10 04:33:28 +01:00
|
|
|
}
|
2011-03-05 21:00:41 +01:00
|
|
|
|
2012-02-07 14:56:58 +01:00
|
|
|
void
|
2012-04-03 09:02:45 +02:00
|
|
|
page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset)
|
2011-04-19 19:24:03 +02:00
|
|
|
{
|
2012-03-26 14:44:56 +02:00
|
|
|
g_return_if_fail(page != NULL);
|
|
|
|
g_return_if_fail(offset != NULL);
|
2012-04-03 09:02:45 +02:00
|
|
|
GtkWidget* widget = zathura_page_get_widget(zathura, page);
|
2011-04-19 19:24:03 +02:00
|
|
|
|
2012-03-26 14:44:56 +02:00
|
|
|
g_return_if_fail(gtk_widget_translate_coordinates(widget,
|
2012-10-09 01:12:18 +02:00
|
|
|
zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true);
|
2011-04-19 19:24:03 +02:00
|
|
|
}
|
2012-01-19 00:37:58 +01:00
|
|
|
|
2013-02-23 16:48:19 +01:00
|
|
|
zathura_rectangle_t
|
|
|
|
rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, double height, double width)
|
2012-02-08 22:23:45 +01:00
|
|
|
{
|
|
|
|
zathura_rectangle_t tmp;
|
|
|
|
switch (degree) {
|
|
|
|
case 90:
|
|
|
|
tmp.x1 = height - rectangle.y2;
|
|
|
|
tmp.x2 = height - rectangle.y1;
|
|
|
|
tmp.y1 = rectangle.x1;
|
|
|
|
tmp.y2 = rectangle.x2;
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
tmp.x1 = width - rectangle.x2;
|
|
|
|
tmp.x2 = width - rectangle.x1;
|
|
|
|
tmp.y1 = height - rectangle.y2;
|
|
|
|
tmp.y2 = height - rectangle.y1;
|
|
|
|
break;
|
|
|
|
case 270:
|
|
|
|
tmp.x1 = rectangle.y1;
|
|
|
|
tmp.x2 = rectangle.y2;
|
|
|
|
tmp.y1 = width - rectangle.x2;
|
|
|
|
tmp.y2 = width - rectangle.x1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tmp.x1 = rectangle.x1;
|
|
|
|
tmp.x2 = rectangle.x2;
|
|
|
|
tmp.y1 = rectangle.y1;
|
|
|
|
tmp.y2 = rectangle.y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2012-01-19 00:37:58 +01:00
|
|
|
zathura_rectangle_t
|
|
|
|
recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle)
|
|
|
|
{
|
2012-03-26 14:44:56 +02:00
|
|
|
if (page == NULL) {
|
|
|
|
goto error_ret;
|
2012-01-19 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
2012-03-26 14:44:56 +02:00
|
|
|
zathura_document_t* document = zathura_page_get_document(page);
|
|
|
|
|
|
|
|
if (document == NULL) {
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
double page_height = zathura_page_get_height(page);
|
|
|
|
double page_width = zathura_page_get_width(page);
|
2012-03-27 21:59:35 +02:00
|
|
|
double scale = zathura_document_get_scale(document);
|
2012-03-26 14:44:56 +02:00
|
|
|
|
2013-02-23 16:48:19 +01:00
|
|
|
zathura_rectangle_t tmp = rotate_rectangle(rectangle, zathura_document_get_rotation(document), page_height, page_width);
|
|
|
|
tmp.x1 *= scale;
|
|
|
|
tmp.x2 *= scale;
|
|
|
|
tmp.y1 *= scale;
|
|
|
|
tmp.y2 *= scale;
|
2012-01-19 00:37:58 +01:00
|
|
|
|
|
|
|
return tmp;
|
2012-03-26 14:44:56 +02:00
|
|
|
|
|
|
|
error_ret:
|
|
|
|
|
|
|
|
return rectangle;
|
2012-01-19 00:37:58 +01:00
|
|
|
}
|
2012-02-08 21:34:53 +01:00
|
|
|
|
2013-02-23 17:18:02 +01:00
|
|
|
double
|
2012-02-08 22:23:45 +01:00
|
|
|
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate)
|
|
|
|
{
|
2013-02-23 17:32:30 +01:00
|
|
|
g_return_val_if_fail(page != NULL && page_height != NULL && page_width != NULL, 0.0);
|
2012-02-08 22:23:45 +01:00
|
|
|
|
2012-03-26 14:44:56 +02:00
|
|
|
zathura_document_t* document = zathura_page_get_document(page);
|
|
|
|
if (document == NULL) {
|
2013-02-23 17:32:30 +01:00
|
|
|
return 0.0;
|
2012-03-26 14:44:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
double height = zathura_page_get_height(page);
|
|
|
|
double width = zathura_page_get_width(page);
|
2012-03-27 21:59:35 +02:00
|
|
|
double scale = zathura_document_get_scale(document);
|
2013-02-23 17:18:02 +01:00
|
|
|
double real_scale;
|
2012-03-26 14:44:56 +02:00
|
|
|
|
2012-03-27 21:59:35 +02:00
|
|
|
if (rotate && zathura_document_get_rotation(document) % 180) {
|
|
|
|
*page_width = ceil(height * scale);
|
|
|
|
*page_height = ceil(width * scale);
|
2013-02-23 17:18:02 +01:00
|
|
|
real_scale = MAX(*page_width / height, *page_height / width);
|
2012-02-08 22:23:45 +01:00
|
|
|
} else {
|
2012-03-27 21:59:35 +02:00
|
|
|
*page_width = ceil(width * scale);
|
|
|
|
*page_height = ceil(height * scale);
|
2013-02-23 17:18:02 +01:00
|
|
|
real_scale = MAX(*page_width / width, *page_height / height);
|
2012-02-08 22:23:45 +01:00
|
|
|
}
|
2013-02-23 17:18:02 +01:00
|
|
|
|
|
|
|
return real_scale;
|
2012-02-08 22:23:45 +01:00
|
|
|
}
|
2012-04-03 09:02:45 +02:00
|
|
|
|
2012-12-13 12:43:49 +01:00
|
|
|
void
|
|
|
|
zathura_get_document_size(zathura_t* zathura,
|
|
|
|
unsigned int cell_height, unsigned int cell_width,
|
|
|
|
unsigned int* height, unsigned int* width)
|
|
|
|
{
|
|
|
|
g_return_if_fail(zathura != NULL && zathura->document != NULL &&
|
|
|
|
height != NULL && width != NULL);
|
|
|
|
|
|
|
|
unsigned int pages_per_row = 1;
|
|
|
|
girara_setting_get(zathura->ui.session, "pages-per-row", &pages_per_row);
|
|
|
|
if (pages_per_row == 0)
|
|
|
|
pages_per_row = 1;
|
|
|
|
|
|
|
|
unsigned int first_page_column = 1;
|
|
|
|
girara_setting_get(zathura->ui.session, "first-page-column", &first_page_column);
|
|
|
|
if (first_page_column < 1)
|
|
|
|
first_page_column = 1;
|
|
|
|
if (first_page_column > pages_per_row)
|
|
|
|
first_page_column = (first_page_column - 1) % pages_per_row + 1;
|
|
|
|
|
|
|
|
int padding = 1;
|
|
|
|
girara_setting_get(zathura->ui.session, "page-padding", &padding);
|
|
|
|
|
|
|
|
double scale = zathura_document_get_scale(zathura->document);
|
|
|
|
|
|
|
|
cell_height = ceil(cell_height * scale);
|
|
|
|
cell_width = ceil(cell_width * scale);
|
|
|
|
|
|
|
|
*width = pages_per_row * cell_width + (pages_per_row - 1) * padding;
|
|
|
|
unsigned int effective_number_of_pages =
|
|
|
|
zathura_document_get_number_of_pages(zathura->document) +
|
|
|
|
first_page_column - 1;
|
|
|
|
unsigned int rows = effective_number_of_pages / pages_per_row +
|
|
|
|
(effective_number_of_pages % pages_per_row ? 1 : 0);
|
|
|
|
*height = rows * cell_height + (rows - 1) * padding;
|
|
|
|
}
|
|
|
|
|
2012-04-03 09:02:45 +02:00
|
|
|
GtkWidget*
|
|
|
|
zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page)
|
|
|
|
{
|
|
|
|
if (zathura == NULL || page == NULL || zathura->pages == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int page_number = zathura_page_get_index(page);
|
|
|
|
|
|
|
|
return zathura->pages[page_number];
|
|
|
|
}
|
2012-04-21 04:59:58 +02:00
|
|
|
|
2012-04-22 19:12:45 +02:00
|
|
|
void
|
|
|
|
document_draw_search_results(zathura_t* zathura, bool value)
|
|
|
|
{
|
|
|
|
if (zathura == NULL || zathura->document == NULL || zathura->pages == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
|
|
|
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
|
|
|
|
g_object_set(zathura->pages[page_id], "draw-search-results", (value == true) ? TRUE : FALSE, NULL);
|
|
|
|
}
|
|
|
|
}
|
2012-07-12 10:37:58 +02:00
|
|
|
|
|
|
|
char*
|
|
|
|
zathura_get_version_string(zathura_t* zathura, bool markup)
|
|
|
|
{
|
2012-10-09 01:12:18 +02:00
|
|
|
if (zathura == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-07-12 10:37:58 +02:00
|
|
|
|
|
|
|
GString* string = g_string_new(NULL);
|
|
|
|
|
|
|
|
/* zathura version */
|
|
|
|
char* zathura_version = g_strdup_printf("zathura %d.%d.%d", ZATHURA_VERSION_MAJOR, ZATHURA_VERSION_MINOR, ZATHURA_VERSION_REV);
|
|
|
|
g_string_append(string, zathura_version);
|
|
|
|
g_free(zathura_version);
|
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
char* format = (markup == true) ? "\n<i>(plugin)</i> %s (%d.%d.%d) <i>(%s)</i>" : "\n(plugin) %s (%d.%d.%d) (%s)";
|
2012-07-12 10:37:58 +02:00
|
|
|
|
|
|
|
/* plugin information */
|
|
|
|
girara_list_t* plugins = zathura_plugin_manager_get_plugins(zathura->plugins.manager);
|
|
|
|
if (plugins != NULL) {
|
|
|
|
GIRARA_LIST_FOREACH(plugins, zathura_plugin_t*, iter, plugin)
|
2012-10-09 01:12:18 +02:00
|
|
|
char* name = zathura_plugin_get_name(plugin);
|
|
|
|
zathura_plugin_version_t version = zathura_plugin_get_version(plugin);
|
|
|
|
char* text = g_strdup_printf(format,
|
|
|
|
(name == NULL) ? "-" : name,
|
|
|
|
version.major,
|
|
|
|
version.minor,
|
|
|
|
version.rev,
|
|
|
|
zathura_plugin_get_path(plugin)
|
|
|
|
);
|
|
|
|
g_string_append(string, text);
|
|
|
|
g_free(text);
|
2012-07-12 10:37:58 +02:00
|
|
|
GIRARA_LIST_FOREACH_END(plugins, zathura_plugin_t*, iter, plugin);
|
|
|
|
}
|
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
char* version = string->str;
|
|
|
|
g_string_free(string, FALSE);
|
2012-07-12 10:37:58 +02:00
|
|
|
|
2012-10-09 01:12:18 +02:00
|
|
|
return version;
|
2012-07-12 10:37:58 +02:00
|
|
|
}
|
2012-08-14 11:45:11 +02:00
|
|
|
|
|
|
|
char*
|
|
|
|
replace_substring(const char* string, const char* old, const char* new)
|
|
|
|
{
|
|
|
|
if (string == NULL || old == NULL || new == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t old_len = strlen(old);
|
|
|
|
size_t new_len = strlen(new);
|
|
|
|
|
|
|
|
/* count occurences */
|
|
|
|
unsigned int count = 0;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
for (i = 0; string[i] != '\0'; i++) {
|
|
|
|
if (strstr(&string[i], old) == &string[i]) {
|
|
|
|
i += (old_len - 1);
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* ret = g_malloc0(sizeof(char) * (i - count * old_len + count * new_len + 1));
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
/* replace */
|
|
|
|
while (*string != '\0') {
|
|
|
|
if (strstr(string, old) == string) {
|
2013-01-25 23:19:26 +01:00
|
|
|
strncpy(&ret[i], new, new_len);
|
2012-08-14 11:45:11 +02:00
|
|
|
i += new_len;
|
|
|
|
string += old_len;
|
|
|
|
} else {
|
|
|
|
ret[i++] = *string++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|