100% found this document useful (1 vote)
2 views

String Algorithms in C: Efficient Text Representation and Search 1st Edition Thomas Mailund download

The document is a promotional and informational text about various programming books by Thomas Mailund, focusing on string algorithms, data structures, and statistical programming in C and R. It includes links to download these books and provides details about the author's background and the content covered in the books. The main book highlighted is 'String Algorithms in C: Efficient Text Representation and Search,' which aims to teach fundamental algorithms and data structures for searching strings with practical C code examples.

Uploaded by

nitkasanzivl
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2 views

String Algorithms in C: Efficient Text Representation and Search 1st Edition Thomas Mailund download

The document is a promotional and informational text about various programming books by Thomas Mailund, focusing on string algorithms, data structures, and statistical programming in C and R. It includes links to download these books and provides details about the author's background and the content covered in the books. The main book highlighted is 'String Algorithms in C: Efficient Text Representation and Search,' which aims to teach fundamental algorithms and data structures for searching strings with practical C code examples.

Uploaded by

nitkasanzivl
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

String Algorithms in C: Efficient Text

Representation and Search 1st Edition Thomas


Mailund download

https://textbookfull.com/product/string-algorithms-in-c-
efficient-text-representation-and-search-1st-edition-thomas-
mailund/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

The Joys of Hashing: Hash Table Programming with C 1st


Edition Thomas Mailund

https://textbookfull.com/product/the-joys-of-hashing-hash-table-
programming-with-c-1st-edition-thomas-mailund/

Pointers in C Programming A Modern Approach to Memory


Management Recursive Data Structures Strings and Arrays
Thomas Mailund

https://textbookfull.com/product/pointers-in-c-programming-a-
modern-approach-to-memory-management-recursive-data-structures-
strings-and-arrays-thomas-mailund/

Domain Specific Languages in R Advanced Statistical


Programming 1st Edition Thomas Mailund

https://textbookfull.com/product/domain-specific-languages-in-r-
advanced-statistical-programming-1st-edition-thomas-mailund/

Domain Specific Languages in R Advanced Statistical


Programming 1st Edition Thomas Mailund

https://textbookfull.com/product/domain-specific-languages-in-r-
advanced-statistical-programming-1st-edition-thomas-mailund-2/
C Data Structures and Algorithms Explore the
possibilities of C for developing a variety of
efficient applications Marcin Jamro

https://textbookfull.com/product/c-data-structures-and-
algorithms-explore-the-possibilities-of-c-for-developing-a-
variety-of-efficient-applications-marcin-jamro/

Functional Data Structures in R: Advanced Statistical


Programming in R Thomas Mailund

https://textbookfull.com/product/functional-data-structures-in-r-
advanced-statistical-programming-in-r-thomas-mailund/

Metaprogramming in R: Advanced Statistical Programming


for Data Science, Analysis and Finance 1st Edition
Thomas Mailund

https://textbookfull.com/product/metaprogramming-in-r-advanced-
statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/

C# Data Structures and Algorithms: Harness the power of


C# to build a diverse range of efficient applications,
2nd Edition Marcin Jamro

https://textbookfull.com/product/c-data-structures-and-
algorithms-harness-the-power-of-c-to-build-a-diverse-range-of-
efficient-applications-2nd-edition-marcin-jamro/

Introducing Markdown and Pandoc Using Markup Language


and Document Converter 1st Edition Thomas Mailund

https://textbookfull.com/product/introducing-markdown-and-pandoc-
using-markup-language-and-document-converter-1st-edition-thomas-
mailund/
String
Algorithms in C
Ef f icient Text Representation and Search

Thomas Mailund

WOW! eBook
www.wowebook.org
String Algorithms in C
Efficient Text Representation
and Search

Thomas Mailund

WOW! eBook
www.wowebook.org
String Algorithms in C: Efficient Text Representation and Search
Thomas Mailund
Aarhus N, Denmark

ISBN-13 (pbk): 978-1-4842-5919-1 ISBN-13 (electronic): 978-1-4842-5920-7


https://doi.org/10.1007/978-1-4842-5920-7

Copyright © 2020 by Thomas Mailund


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by Jonathan J Castellon on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484259191. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper

WOW! eBook
www.wowebook.org
Table of Contents
About the Author���������������������������������������������������������������������������������������������������� vii

About the Technical Reviewer��������������������������������������������������������������������������������� ix

Chapter 1: Introduction�������������������������������������������������������������������������������������������� 1
Notation and conventions������������������������������������������������������������������������������������������������������������� 1
Graphical notation������������������������������������������������������������������������������������������������������������������������� 2
Code conventions�������������������������������������������������������������������������������������������������������������������������� 3
Reporting a sequence of results��������������������������������������������������������������������������������������������������� 5

Chapter 2: Classical algorithms for exact search�������������������������������������������������� 11


Naïve algorithm��������������������������������������������������������������������������������������������������������������������������� 12
Border array and border search�������������������������������������������������������������������������������������������������� 14
Borders and border arrays���������������������������������������������������������������������������������������������������������� 15
Exact search using borders�������������������������������������������������������������������������������������������������������� 18
Knuth-Morris-Pratt���������������������������������������������������������������������������������������������������������������������� 21
Boyer-Moore-Horspool���������������������������������������������������������������������������������������������������������������� 28
Extended rightmost table������������������������������������������������������������������������������������������������������������ 35
Boyer-Moore������������������������������������������������������������������������������������������������������������������������������� 38
Jump rule one����������������������������������������������������������������������������������������������������������������������� 40
Second jump table����������������������������������������������������������������������������������������������������������������� 53
Combining the jump rules����������������������������������������������������������������������������������������������������� 55
Aho-Corasick������������������������������������������������������������������������������������������������������������������������������� 58
Tries��������������������������������������������������������������������������������������������������������������������������������������� 58
Comparisons������������������������������������������������������������������������������������������������������������������������������� 83

iii

WOW! eBook
www.wowebook.org
Table of Contents

Chapter 3: Suffix trees�������������������������������������������������������������������������������������������� 87


Compacted trie and suffix representation����������������������������������������������������������������������������������� 88
Naïve construction algorithm������������������������������������������������������������������������������������������������������ 93
Suffix trees and the SA and LCP arrays������������������������������������������������������������������������������������ 101
Constructing the SA and LCP arrays������������������������������������������������������������������������������������ 101
Constructing the suffix tree from the SA and LCP arrays���������������������������������������������������� 104
McCreight’s algorithm��������������������������������������������������������������������������������������������������������������� 110
Searching with suffix trees������������������������������������������������������������������������������������������������������� 123
Leaf iterators����������������������������������������������������������������������������������������������������������������������� 125
Comparisons����������������������������������������������������������������������������������������������������������������������������� 131

Chapter 4: Suffix arrays���������������������������������������������������������������������������������������� 139


Constructing suffix arrays��������������������������������������������������������������������������������������������������������� 142
Trivial constructions—Comparison-based sorting�������������������������������������������������������������� 142
The skew algorithm������������������������������������������������������������������������������������������������������������� 145
The SA-IS algorithm������������������������������������������������������������������������������������������������������������������ 167
Remapping�������������������������������������������������������������������������������������������������������������������������� 176
Implementing the algorithm������������������������������������������������������������������������������������������������ 179
Memory reduction��������������������������������������������������������������������������������������������������������������� 193
Searching using suffix arrays��������������������������������������������������������������������������������������������������� 206
Binary search���������������������������������������������������������������������������������������������������������������������� 206
Burrows-Wheeler transform–based search������������������������������������������������������������������������ 214
Getting the longest common prefix (LCP) array������������������������������������������������������������������������ 221
Comparisons����������������������������������������������������������������������������������������������������������������������������� 225

Chapter 5: Approximate search���������������������������������������������������������������������������� 235


Local alignment and CIGAR notation����������������������������������������������������������������������������������������� 235
Brute force approach���������������������������������������������������������������������������������������������������������������� 238
Building an edit cloud���������������������������������������������������������������������������������������������������������� 238
Suffix trees�������������������������������������������������������������������������������������������������������������������������������� 250
The Li-Durbin algorithm������������������������������������������������������������������������������������������������������������ 258
Comparisons����������������������������������������������������������������������������������������������������������������������������� 269

iv

WOW! eBook
www.wowebook.org
Table of Contents

Chapter 6: Conclusions����������������������������������������������������������������������������������������� 273

Appendix: Fundamental data structures�������������������������������������������������������������� 275


V ectors�������������������������������������������������������������������������������������������������������������������������������������� 275
Lists������������������������������������������������������������������������������������������������������������������������������������������ 281
Queues�������������������������������������������������������������������������������������������������������������������������������������� 282

Index��������������������������������������������������������������������������������������������������������������������� 287

WOW! eBook
www.wowebook.org
About the Author
Thomas Mailund is an associate professor in bioinformatics at Aarhus University,
Denmark. He has a background in math and computer science. For the past decade,
his main focus has been on genetics and evolutionary studies, particularly comparative
genomics, speciation, and gene flow between emerging species. He has published R
Data Science Quick Reference, The Joys of Hashing, Domain-Specific Languages in R,
Beginning Data Science in R, Functional Programming in R, and Metaprogramming in R,
all from Apress, as well as other books.

vii

WOW! eBook
www.wowebook.org
About the Technical Reviewer
Jason Whitehorn is an experienced entrepreneur and
software developer and has helped many companies
automate and enhance their business solutions through data
synchronization, SaaS architecture, and machine learning.
Jason obtained his Bachelor of Science in Computer Science
from Arkansas State University, but he traces his passion
for development back many years before then, having first
taught himself to program BASIC on his family’s computer
while still in middle school.
When he’s not mentoring and helping his team at work,
writing, or pursuing one of his many side projects, Jason enjoys spending time with his
wife and four children and living in the Tulsa, Oklahoma region. More information about
Jason can be found on his website: ­https://jason.whitehorn.us.

ix

WOW! eBook
www.wowebook.org
CHAPTER 1

Introduction
Algorithms operating on strings are fundamental to many computer programs, and in
particular searching for one string in another is the core of many algorithms. An example
is searching for a word in a text document, where we want to know everywhere it occurs.
This search can be exact, meaning that we are looking for the positions where the word
occurs verbatim, or approximative, where we allow for some spelling mistakes.
This book will teach you fundamental algorithms and data structures for exact and
approximative search. The goal of the book is not to cover the theory behind the material
in great detail. However, we will see theoretical considerations where relevant. The
purpose of the book is to give you examples of how the algorithms can be implemented.
For every algorithm and data structure in the book, I will present working C code and
nowhere will I use pseudocode. When I argue for the correctness and running time of
algorithms, I do so intentionally informal. I aim at giving you an idea about why the
algorithms solve a specific problem in a given time, but I will not mathematically prove so.
You can copy all the algorithms and data structures in this book from the pages,
but they are also available in a library on GitHub: https://github.com/mailund/
stralg. You can download and link against the library or copy snippets of code into
your own projects. On GitHub you can also find all the programs I have used for time
measurement experiments so you can compare the algorithm’s performance on your
own machine and in your own runtime environment.

N
 otation and conventions
Unless otherwise stated, we use x, y, and p to refer to strings and i, j, k, l, and h to denote
indices. We use 𝜖 to denote the empty string. We use a, b, and c for single characters. As
in C, we do not distinguish between strings and pointers to a sequence of characters.
Since the book is about algorithms in C, the notation we use matches that which is
used for strings, pointers, and arrays in C. Arrays and strings are indexed from zero,

1
© Thomas Mailund 2020
T. Mailund, String Algorithms in C, https://doi.org/10.1007/978-1-4842-5920-7_1

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

that is, A[0] is the first value in array A (and x[0] is the first character in string x). The ith
character in a string is at index i − 1.
When we refer to a substring, we define it using two indices, i and j, i ≤ j, and we
write x[i, j] for the substring. The first index is included and the second is not, that is,
x[i, j] = x[i]x[i + 1] · · · x[ j − 1]. If a string has length n, then the substring x[0, n] is the full
string. If we have a character a and a string x, then ax denotes the string that has a as its
first character and is then followed by the string x. We use ak to denote a sequence of as
of length k. The string a3 x has a as its first three characters and is then followed by x.
A substring that starts at index 0, x[0, i], is a prefix of the string, and it is a proper prefix
if it is neither the empty string x[0, 0] = 𝜖 nor the full string x[0, n]. A substring that ends
in n, x[i, n], is a suffix, and it is a proper suffix if it is neither the empty string nor the full
string. We will sometimes use x[i, ] for this suffix.
We use $ to denote a sentinel in a string, that is, it is a character that is not found in
the rest of the string. It is typically placed at the end of the string. The zero-terminated
C strings have the zero byte as their termination sentinel, and unless otherwise stated,
$ refers to that. All C strings x have a zero sentinel at index n if the string has length n,
x = x[0]x[1] · · · x[n − 1]0. For some algorithms, the sentinel is essential; in others, it is not.
We will leave it out of the notation when a sentinel isn’t needed for an algorithm, but
naturally include the sentinel when it is necessary.

G
 raphical notation
Most data structures and algorithmic ideas are simpler to grasp if we use drawings to
capture the structure of strings rather than textual notation. Because of this, I have chosen to
provide more figures in this book than you will typically see in a book on algorithms. I hope
you will appreciate it. If there is anything you find unclear about an algorithm, I suggest you
try to draw key strings yourself and work out the properties you have problems with.
In figures, we represent strings as rectangles. We show indices into a string as arrows
pointing to the index in the string; see Figure 1-1. In this notation, we do not distinguish
between pointers and indices. If a variable is an index j and it points into x, then what
it points to is x[ j], naturally. If the variable is a pointer, y, then what it points to is ∗y.
Whether we are working with pointers or indices should be clear from the context. It will
undoubtedly be clear from the C implementations. We represent substrings by boxes of
a different color inside the original string-rectangle. If we specify the indices defining the
substring, we include their start and stop index (where the stop index points one after
the end of the substring).
2

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

Figure 1-1. Graphical string notation


When we compare two strings, we imagine that we align the boxes representing
them, so the parts we are comparing are on top of each other. For example, if we
compare the character at index j in a string x with the character at index i in another
string p, then we draw a box representing x over a box representing p, and we draw
pointers for the two indices; see Figure 1-2. Since we are comparing the characters in the
two indices, the two pointers are pointing at each other. Conceptually, we imagine that p
is aligned under x starting at position j − i.

Figure 1-2. Graphical notation for comparing indices in two different strings

C
 ode conventions
There is a trade-off between long variables and type names and then the line within a
book. In many cases, I have had to use an indentation that you might not be used to. In
function prototypes and function definitions, I will generally write with one variable per
line, indented under the function return type and name, for example:

void compute_z_array(
    const unsigned char *x,
    uint32_t n,
    uint32_t *Z
);
3

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

void compute_reverse_z_array(
    const unsigned char *x,
    uint32_t m,
    uint32_t *Z
);

If a return type name is long, I will put it on a separate line:

static inline uint32_t


edge_length(struct suffix_tree_node *n) {
    return range_length(n->range);
}
struct suffix_tree *
mccreight_suffix_tree(
    const unsigned char *string
);
struct suffix_tree *
lcp_suffix_tree(
    const unsigned char *string,
    uint32_t *sa,
    uint32_t *lcp
);
struct suffix_tree_node *
st_search(
    struct suffix_tree *st,
    const char *pattern
);

I make an exception for functions that take no arguments, that is, have void as their
argument type.
There are many places where an algorithm needs to use characters to look up in
arrays. If you use the conventional C string type, char *, then the character can be either
signed or unsigned, depending on your compiler, and you have to cast the type to avoid
warnings. A couple of places we also have to make assumptions about the alphabet
size. Because of this, I use arrays of uint8_t with a zero termination sentinel as strings.
On practically all platforms, char is 8 bits so this type is, for all intents and purposes, C
strings. We are just guaranteed that we can use it unsigned and that the alphabet size

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

is 256. Occasionally it is necessary to cast a uint8_t * string to a C string. A direct cast,


(char *)x, will most likely work unless you are on an exotic platform. If it doesn’t, you
have to build a char buffer and copy characters byte by byte. It has to be a very exotic
platform if you cannot store 8 bits in a char! Because I assume that you can always cast to
char *, I will use the C library string functions (with a cast) when this is appropriate. It is
a small matter to write your own if it is necessary.
I will use uint32_t for indices, assuming that strings are short enough that we
can index them with 32 bits. You can change it as needed, but I find it a good trade-­
off between likely lengths of strings and the space I need for data structures. I work in
bioinformatics, so hundreds of millions of characters are usually the longest I encounter.

Reporting a sequence of results


In search algorithms, we report each occurrence of a pattern. This sounds
straightforward, but there is a design choice in how we report the occurrences. Consider
the following algorithm. It is the Boyer-Moore-Horspool (BMH) algorithm that you
will see in the next chapter. It takes a string, x, and a pattern, p, and searches for all
occurrences of p in x. First, it does some preprocessing, and then it searches. This is a
general pattern for the algorithms in the next chapter. In the search, when it has found
an occurrence of p, it reports the position by calling the REPORT(j) function.

void bmh_search(
    const uint8_t *x,
    const uint8_t *p
) {
    uint32_t n = strlen((char *)x);
    uint32_t m = strlen((char *)p);

    // Preprocessing
    int jump_table[256];

    for (int k = 0; k < 256; k++) {


        jump_table[k] = m;
    }
    for (int k = 0; k < m - 1; k++) {
        jump_table[p[k]] = m - k - 1;
    }
5

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

    // Searching
    for (uint32_t j = 0;
         j < n - m + 1;
         j += jump_table[x[j + m - 1]]) {

        int i = m - 1;
        while (i > 0 && p[i] == x[j + i])
            --i;
        if (i == 0 && p[0] == x[j]) {
            REPORT(j);
        }
    }
}

If a global report function is all you need in your program, then this is an excellent
solution. Often, however, we need different reporting functions for separate calls to the
search function. Or we need the report function to collect data for further processing
(and preferably not use global variables). We need some handle to choose different
report functions and to provide them with data.
One approach is using callbacks: Provide a report function and data argument to the
search function and call the report function with the data when we find an occurrence.
In the following implementation, I am assuming we have defined the function type for
reporting, report_function, and the type for data we can add to it, report_function_
data, somewhere outside of the search function.

void bmh_search_callback(
    const uint8_t *x,
    const uint8_t *p,
    report_function report,
    report_function_data data
) {
    uint32_t n = strlen((char *)x);
    uint32_t = strlen((char *)p);

    // Preprocessing
    uint32_t jump_table[256];

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

    for (int k = 0; k < 256; k++) {


        jump_table[k] = m;
    }
    for (int k = 0; k < m - 1; k++) {
        jump_table[p[k]] = m - k - 1;
    }

    // Searching
    for (uint32_t j = 0;
         j < n - m + 1;
         j += jump_table[x[j + m - 1]]) {

        int i = m - 1;
        while (i > 0 && p[i] == x[j + i])
            --i;
        if (i == 0 && p[0] == x[j]) {
            report(j, data);
        }
    }
}

Callback functions have their uses, especially to handle events in interactive


programs, but also some substantial drawbacks. To use them, you have to split the
control flow of your program into different functions which hurts readability. Especially
if you need to handle nested loops, for example, iterate over all nodes in a tree and for
each node iterate over the leaves in another tree where for each node-leaf pair you find
occurrences… (the example here is made up, but there are plenty of real algorithms with
nested loops, and we will see some later in the book).
We can get the control flow back to the calling function using the iterator design
pattern. We define an iterator structure that holds information about the loop state,
and we provide functions for setting it up, progressing to the next point in the loop, and
reporting a match and then a function for freeing resources once the iterator is done.
The general pattern for using an iterator looks like this:

    struct iterator iter;


    struct match match;
    iter_init(&iter, data);

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

    while (next_func(&iter, &match)) {


        // Process occurrence
    }
    iter_dealloc(&iter);

The iterator structure contains the loop information. That means it must save the
preprocessing data from when we create it and information about how to resume the
loop after each time it is suspended. To report occurrences, it takes a “match” structure
through which it can inform the caller about where matches occur. The iterator is
initialized with data that determines what it should loop over. The loop is handled
using a “next” function that returns true if there is another match (and if it does it will
have filled out match). If there are no more matches, and the loop terminates, then it
returns false. The iterator might contain allocated resources, so there should always be a
function for freeing those.
In an iterator for the BMH, we would keep the string, pattern, and table we build in
the preprocessing.

struct bmh_match_iter {
    const uint8_t *x; uint32_t n;
    const uint8_t *p; uint32_t m;
    int jump_table[256];
    uint32_t j;
};
struct match {
    uint32_t pos;
};

We put the preprocessing in the iterator initialization function

void init_bmh_match_iter(
    struct bmh_match_iter *iter,
    const uint8_t *x, uint32_t n,
    const uint8_t *p, uint32_t m
) {
    // Preprocessing
    iter->j = 0;
    iter->x = x; iter->n = n;
    iter->p = p; iter->m = m;
8

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

    for (int k = 0; k < 256; k++) {


        iter->jump_table[k] = m;
    }
    for (int k = 0; k < m - 1; k++) {
        iter->jump_table[p[k]] = m - k - 1;
    }
}

and in the next function we do the search

bool next_bmh_match(
    struct bmh_match_iter *iter,
    struct match *match
) {
    const uint8_t *x = iter->x;
    const uint8_t *p = iter->p;
    uint32_t n = iter->n;
    uint32_t m = iter->m;
    int *jump_table = iter->jump_table;

    // Searching
    for (uint32_t j = iter->j;
         j < n - m + 1;
         j += jump_table[x[j + m - 1]]) {

        int i = m - 1;
        while (i > 0 && p[i] == x[j + i]) {
            i--;
        }
        if (i == 0 && p[0] == x[j]) {
            match->pos = j;
            iter->j = j +
                   jump_table[x[j + m - 1]];
            return true;
        }
    }
    return false;
}
9

WOW! eBook
www.wowebook.org
Chapter 1 Introduction

We set up the loop with information from the iterator and search from there. If we
find an occurrence, we store the new loop information in the iterator and the match
information in the match structure and return true. If we reach the end of the loop, we
report false.
We have not allocated any resources when we initialized the iterator, so we do not
need to free anything.

void dealloc_bmh_match_iter(
    struct bmh_match_iter *iter
) {
    // Nothing to do here
}

Since the deallocation function doesn’t do anything, we could leave it out. Still,
consistency in the use of iterators helps avoid problems. Plus, should we at some point
add resources to the iterator, then it is easier to update one function than change all the
places in the code that should now call a deallocation function.
Iterators complicate the implementation of algorithms, especially if they are
recursive and the iterator needs to keep track of a stack. Still, they greatly simplify the
user interface to your algorithms, which makes it worthwhile to spend a little extra time
implementing them. In this book, I will use iterators throughout.

10

WOW! eBook
www.wowebook.org
CHAPTER 2

Classical algorithms
for exact search
We kick the book off by looking at classical algorithms for exact search, that is, finding
positions in a string where a pattern string matches precisely. This problem is so
fundamental that it received much attention in the very early days of computing, and by
now, there are tens if not hundreds of approaches. In this chapter, we see a few classics.
Recall that we use iterators whenever we have an algorithm that loops over results
that should be reported. All iterators must be initialized, and the resources they hold must
be deallocated when we no longer need the iterator. When we loop, we have a function
that returns true when there is something to report and false when the loop is done. The
values the iterator reports are put in a structure that we pass along to the function that
iterates to the next value to report. For the algorithms in this chapter, we initialize the
iterators with the string in which we search, the pattern we search for, and the lengths of
the two strings. Iterating over all occurrences of the pattern follows this structure:

struct iterator iter;


struct match match;
iter_init(iter, x, strlen(x), p, strlen(p));
while (next_func(&iter, &match)) {
   // Process occurrence
}
iter_dealloc(&iter);

When we report an occurrence, we get the position of the match, so the structure the
iterator use for reporting is this:

struct match {
    uint32_t pos;
};

11
© Thomas Mailund 2020
T. Mailund, String Algorithms in C, https://doi.org/10.1007/978-1-4842-5920-7_2

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

N
 aïve algorithm
The simplest way imaginable for exact search is to iteratively move through the string
x, with an index j that conceptually runs the pattern p along x, and at each index start
matching the pattern against the string using another index, i (see Figure 2-1). The
algorithm has two loops, one that iterates j through x and one that iterates i through
p, matching x[i + j] against p[i] along the way. We run the inner loop until we see a
mismatch or until we reach the end of the pattern. In the former case, we move p one
step forward and try matching again. In the second case, we report an occurrence at
position j and then increment the index so we can start matching at the next position. We
stop the outer loop when index j is greater than n − m. If it is, there isn’t room for a match
that doesn’t run past the end of x.

Figure 2-1. Exact search with the naïve approach

We terminate the comparison of x[i + j] and p[i] when we see a mismatch, so in the best
case, where the first character in p never matches a character in x, the algorithm runs in
time O(n) where n is the length of x. In the worst case, we match all the way to the end of p
at each position, and in that case, the running time is O(nm) where m is the length of p.
To implement the algorithm using an iterator, the iterator needs to remember
the string to search in and the pattern to search for—so we do not need to pass these
along each time we increment the iterator with potentials for errors if we use the wrong
strings—and we keep track of how far into the string we have searched.

struct naive_match_iter {
    const uint8_t *x; uint32_t n;
    const uint8_t *p; uint32_t m;
    uint32_t current_index;
};

12

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

When we initialize the iterator, we remember the two strings and set the current
index to zero—before we start iterating we are at the beginning of the string.

void init_naive_match_iter(
    struct naive_match_iter *iter,
    const uint8_t *x, uint32_t n,
    const uint8_t *p, uint32_t m
) {
    iter->x = x; iter->n = n;
    iter->p = p; iter->m = m;
    iter->current_index = 0;
    iter->current_index = 0;
}

When we increment the iterator, we follow the algorithm as described earlier except
that we start the outer loop at the index saved in the iterator. We search from this index in
an outer loop, and at each new index, we try to match the pattern with an inner loop. We
break the inner loop if we see a mismatching character, and if the inner loop reaches the
end, we have a match and report it. Before we return, we set the iterator index and store
the matching position in the match structure.

bool next_naive_match(
    struct naive_match_iter *iter,
    struct match *match
) {
    uint32_t n = iter->n, m = iter->m;
    const uint8_t *x = iter->x;
    const uint8_t *p = iter->p;

    if (m > n) return false;


    if (m == 0) return false;

    for (uint32_t j = iter->current_index; j <= n - m; j++) {


        uint32_t i = 0;
        while (i < m && x[j+i] == p[i]) {
            i++;
        }

13

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

        if (i == m) {
            iter->current_index = j + 1;
            match->pos = j;
            return true;
        }
    }

    return false;
}

The code

    if (m > n)  return false;


    if (m == 0) return false;

makes sure that it is possible to match the pattern at all and that the pattern isn’t
empty. This is something we could also test when we initialize the iterator. However, we
do not have a way of reporting that we do not have a possible match there, so we put the
test in the “next” function.
We do not allocate any resources when we initialize the iterator, so we do not need to
do anything when deallocating it either. We still need the deallocator function, however,
so we always use the same design pattern when we use iterators. To make sure that if we,
at some point in the future, need to free something that we put in an iterator, then all
users of the iterator (should) have added code for this.

void dealloc_naive_match_iter(
    struct naive_match_iter *iter
) {
    // Nothing to do here...
}

Border array and border search


It is possible to get O(n + m) running times for both best and worst case, and several
algorithms exist for this. We will see several in the following sections. The first one is
based on the so-called borders of strings.

14

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

Borders and border arrays


A border of a string is any substring that is both a prefix and a suffix of the said string; see
Figure 2-2. For example, the string x = ababa has borders aba, a, and the empty string.
There is always at least one border per string—the empty string. It is possible to list all
borders by brute force. For each index i in x, test if the substrings x[0, i] matches the
string x[n − i, n]. This approach makes time O(n) per comparison, and we need it for all
possible borders which means that we end up with a running time of O(n2). It is possible
to compute the longest border in linear time, as we shall see. The way we compute it
shows that sometimes more is less; we will compute more than the length of the longest
suffix. What we will compute is the border array. This is an array that for each index i
holds the length of the longest border of string x[0, i]. Consider x = ababa. For index 0 we
have string a which has border a, so the first element in the border array is 1. The string
ab only has the trivial, nonempty border, so the border array value is zero. The next string
is aba with border a, so we get 1 again. Now abab has borders ab, so the border array
holds 2. The full string x = ababa with border aba so its border array looks like
ba = [1, 0, 1, 2, 3].

Figure 2-2. A string with three borders

We can make the following observation about borders and border arrays: The longest
border of x[0, i] is either the empty string or an extension of a border of x[0, i − 1]. If the
letter at x[i] is a, the border of x[0, i] is some string y followed by a. The y string must be
both at the beginning and end of x[0, i − 1] (see Figure 2-3), so it is a border of x[0, i − 1].
The longest border for x[0, i] is the longest border of x[0, i − 1] that is followed by a (which
may be the empty border if the string x begins with a) or the empty border if there is no
border we can extend with a.
Another observation is that if you have two borders to a string, then the shorter of the
two is a border of the longer; see Figure 2-4.

15

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

The two observations combined gives us an approach to computing the border


array. The first string has the empty border as its only border, and after that, we can use
the border array up to i − 1 to compute the length of the longest border of x[0, i]. We start
by testing if we can extend the longest border with x[i], and if so, ba[i] = ba[i − 1] + 1.
Otherwise, we look at the second-longest border, which must be the longest border of
x[0, ba[i − 1]]. If the character after this border is x[i], then ba[i] = ba[ba[i − 1]] + 1.
We continue this way until we have found a border we can extend (see Figure 2-5). If we
reach the empty border, we have a special case—either we can extend the empty border
because x[0] = x[i], in which case ba[i] = 1, or we cannot extend the border because
x[0] ≠ x[i], in which case ba[i] = 0.

Figure 2-3. Extending a border

Figure 2-4. A shorter border is always a border of a longer border

16

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

Figure 2-5. Searching for the longest border we can extend with letter a

An implementation of the border array construction algorithm can look like this:

    ba[0] = 0;
    for (uint32_t i = 1; i < m; ++i) {
        uint32_t b = ba[i - 1];
        while (b > 0 && x[i] != x[b])
            b = ba[b - 1];
        ba[i] = (x[i] == x[b]) ? b + 1 : 0;
    }

The running time is m for a string x of length m. It is straightforward to see that


the outer loop only runs m iterations but perhaps less easy to see that the inner loop
is bounded by m iterations in total. But observe that in the outer loop, we at most
increment b by one per iteration. We can assign b + 1 to ba[i] in the last statement in the
inner loop and then get that value in the first line of the next iteration, but at no other
point do we increment a value. In the inner loop, we always decrease b—when we get the
border of b − 1, we always get a smaller value than b. We don’t allow b to go below zero in
the inner loop, so the total number of iterations of that loop is bounded by how much the
outer loop increase b. That is at most one per iteration, so we can decrement b by at most
m, and therefore the total number of iterations of the inner loop is bounded by O(m).

17

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

Exact search using borders


The reason we built the border array was to do an exact search, so how does the array
help us? Imagine we build a string consisting of the pattern we search for, p, followed
by the string we search in, x, separated by a sentinel, $ character not found elsewhere in
the two strings, y = p$x. The sentinel ensures that all borders are less than the length of
p, m, and anywhere we have a border of length m, we must have an occurrence of p (see
Figure 2-6). In the figure, the indices are into the p$x string and not into x, but you can
remap this by subtracting m + 1. The start index of the match is i − m + 1 rather than the
more natural i − m because index i is at the end of the match and not one past it.
We can construct the string p$x in linear time and compute the border array—and
report occurrences in the process—in linear time, O(m + n). You don’t need to create
the concatenated string, though. You can build the border array for p and use that when
computing the border array for x. You pretend that p is prepended to x. When you do
this, the sentinel between p and x is the null-termination sentinel in the C-string p.

Figure 2-6. Searching using a border array

An iterator that searches a string with this algorithm must contain the border
array of p, the index into x we have reached, and the b variable from the border array
construction algorithm.

struct border_match_iter {
    const uint8_t *x; uint32_t n;
    const uint8_t *p; uint32_t m;
    uint32_t *border_array;
    uint32_t i; uint32_t b;
};

18

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

When we initialize the iterator, we set its index to zero. That, after all, is where we
start searching in x. We also set the iterator’s b variable to zero. We imagine that we start
the search after a sentinel, so the longest border at the start index for x has length zero.
We then allocate and compute the border array.

void init_border_match_iter(
    struct border_match_iter *iter,
    const uint8_t *x, uint32_t n,
    const uint8_t *p, uint32_t m
) {
    iter->x = x; iter->n = n;
    iter->p = p; iter->m = m;
    iter->i = iter->b = 0;

    uint32_t *ba = malloc(m * sizeof(uint32_t));


    compute_border_array(p, m, ba);
    iter->border_array = ba;
}

Since we allocated the border array when we initialized the iterator, we need to free it
again when we deallocate it.

void dealloc_border_match_iter(
    struct border_match_iter *iter
) {
    free(iter->border_array);
}

A third of my implementation for incrementing the following iterator is setting up


aliases for the variables in the iterator, so I don’t have to write iter->b and iter->m
for variables b and m, respectively. Other than that, there are the tests for whether it is
possible at all to have a match, that we also saw in the previous section, and then there is
the border array construction algorithm again, except that we never update an array but
instead report when we get a border of length m.

19

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

bool next_border_match(
    struct border_match_iter *iter,
    struct match *match
) {
    const uint8_t *x = iter->x;
    const uint8_t *p = iter->p;
    uint32_t *ba = iter->border_array;
    uint32_t b = iter->b;
    uint32_t m = iter->m;
    uint32_t n = iter->n;

    if (m > n) return false;


    if (m == 0) return false;

    for (uint32_t i = iter->i; i < iter->n; ++i) {


        while (b > 0 && x[i] != p[b])
            b = ba[b - 1];
        b = (x[i] == p[b]) ? b + 1 : 0;
        if (b == m) {
            iter->i = i + 1;
            iter->b = b;
            match->pos = i - m + 1;
            return true;
        }
    }

    return false;
}

When we report an occurrence, we naturally set the position we matched in the


report structure, and we remember the border and index positions.

20

WOW! eBook
www.wowebook.org
Chapter 2 Classical algorithms for exact search

K
 nuth-Morris-Pratt
The Knuth-Morris-Pratt (KMP) algorithm also uses borders to achieve a best- and worst-­
case running time of O(n + m), but it uses the borders in a slightly different way. Before
we get to the algorithm, however, I want to convince you that we can, conceptually, move
the pattern p through x in two different ways; see Figure 2-7. We can let j be an index
into x and imagine p starting there. When we test if p matches there, we use a pointer
into p, i, and test x[ j + i] against p[i] for increasing i. To move p to another position in x,
we change j, for example, to slide p one position to the right we increment j by one.
Alternatively, we can imagine p aligned at position j − i for some index j in x and an
index i into p. If we change i, we move j − i so we move p. If, for example, we want
to move p one step to the right, we can decrement i by one. To understand how the
KMP algorithm works, it is useful to think about moving p in the second way. We will
increment the j and i indices when matching characters, but when we get a mismatch,
we move p by decrementing i.
The idea in KMP is to move p along x as we would in the naïve algorithm, but move
a little faster when we have a mismatch. We use index j to point into x and i to point
into p. We match x[ j] against p[i] as we scan along x and the pattern is aligned against
x at index j − i. We can move p’s position by modifying either i or j. Consider a place
in the algorithm where we have matched p[0, i] against x[ j − i, j] and see a mismatch.
In the naïve algorithm, we would move p one step to the right and start matching p
again at that position. We would set i to zero to start matching from the beginning of p,
and we would decrement j to j − i + 1 to match at the new position at which we would
match p. With KMP we will skip positions where we know that p cannot match, and we
use borders to do this.

21

WOW! eBook
www.wowebook.org
Another Random Scribd Document
with Unrelated Content
C’est singulier comme l’habitude nous rend indifférents pour les
choses les plus révoltantes, à un tel degré que nous ne les voyons pas,
quoique tous les jours elles se passent sous nos yeux.
Ainsi, une petite bourgeoise qui a de l’ordre et qui tient bien sa maison,
quelque jolie, mignonne et dégoûtée qu’elle puisse être,—envoie le matin
sa cuisinière à une de ces morgues où les bouchers étendent des cadavres
d’animaux—sans que cela attriste ni dégoûte les passants.
Puis, vers six heures, on se met à table,—et la maîtresse du logis,—
bourgeoise—ou non,—supposez-la, si vous voulez, la plus élégante et la
plus belle,—la plus éthérée et la plus diaphane,—dissèque et fouille
successivement divers cadavres, s’efforçant de se rappeler de quel morceau
du corps mort aime à se repaître tel ou tel convive.
Celui-ci veut que le cadavre soit encore saignant;
Cet autre le préfère un peu plus cuit;
Elle engage son voisin à manger l’œil du veau,—ou telle autre partie du
cadavre qui passe pour plus délicate et plus recherchée.
Voici un homme qui n’a plus faim;—mais il mange encore.—C’est si
amusant de faire tenir dans son estomac le plus de cadavre possible!—
D’ailleurs, quelques-uns se font gloire d’être gros mangeurs,—et c’est leur
position dans le monde.
Et puis, on a mêlé à tous ces corps morts des ingrédients qui en hâtent la
décomposition dans l’estomac et permettent d’en entasser davantage.—
Entre les animaux qui mange de la chair,—l’homme est le seul qui en
mange pour son plaisir, c’est-à-dire au delà de sa faim.
De telle sorte qu’il m’est arrivé plus d’une fois—de voir à mes yeux se
métamorphoser tout à coup la femme la plus gracieuse, donnant à dîner,—
en une goule partageant un cadavre à une volée de corbeaux affamés.
Il est vrai qu’on a ajouté à tout cela l’usage dégoûtant de se rincer la
bouche à table,—sordide propreté dont, pour ma part, j’ai soin de
m’abstenir.
A propos de dîner, il faut encore remarquer que beaucoup de gens,
en invitant, songent beaucoup moins à être agréables aux gens qu’ils
reçoivent qu’à les écraser par l’opulence de leur maison,—beaucoup plus à
les étonner qu’à les nourrir.—C’est dans ces maisons surtout qu’on mange
des primeurs,—c’est-à-dire des légumes qui ont besoin d’être étiquetés pour
qu’on ne les prenne pas au goût pour une seule et même herbe sans saveur.
Beaucoup de personnes, en vous donnant des pois verts à certaines époques,
n’ont évidemment d’autre intention que de vous montrer des pois chers.
J’ai déjà, à plusieurs reprises, donné à M. le comte de Montalivet la
preuve d’estime de lui dénoncer à lui-même les abus qui se commettent
dans son administration.
Je viens aujourd’hui lui apprendre qu’on fait du roi de France un
jardinier et un fruitier,—et que les autres jardiniers et les autres fruitiers, ses
confrères, se plaignent amèrement de lui.
Il y a à Versailles,—au château,—un potager fort beau et fort bien cultivé
par le jardinier Grison. Ce potager produit beaucoup au delà de la
consommation du château, surtout en fruits et en légumes de primeurs;—
vous croyez peut-être que le surplus est consacré à des présents.
Nullement,—on le vend à beaux deniers comptants à divers fruitiers de
Paris.
Et, comme ceux qui vendent les produits de Versailles les ont pour rien,
ils les donnent aux marchands à un prix auquel les producteurs industriels
ne peuvent abaisser les leurs.
Pour vous montrer que je suis bien instruit, nous allons procéder par
exemples.
EXEMPLE:—Il n’y a qu’un seul jardinier qui fasse des haricots verts de
primeur,—c’est un nommé Gauthier qui demeure au Petit-Montrouge.
Cette année, au 20 février, on n’avait encore vendu que deux fois des
haricots verts à Paris.
Les premiers par le roi,—les seconds par M. de Rothschild, qui a un
jardin à Boulogne,—à Maillez, fruitier, marché Saint-Honoré.
Aujourd’hui Gauthier, qui, avec moins de ressources que ses deux
rivaux, arrive cependant presque en même temps qu’eux,—est obligé, pour
rentrer dans ses frais, de vendre ses haricots vingt ou vingt-quatre francs la
livre,—tandis que ses concurrents, le roi de France et M. de Rothschild, les
donnent à meilleur marché.
L’année dernière,—Gauthier, plutôt que de donner ses haricots à vil prix,
a mieux aimé en faire des présents.
C’est agir royalement.
AUTRE EXEMPLE:—L’an dernier, à Trianon, pour un dîner qui devait avoir
lieu, on avait demandé trente ananas au potager de Versailles;—le dîner
n’eut pas lieu, et le lendemain les ananas étaient vendus à Bailli, glacier, rue
Neuve-des-Petits-Champs,—à un prix auquel ne peuvent les céder les
producteurs, auxquels chaque ananas coûte de huit à quinze francs.
Autrefois, les cultivateurs de Versailles obtenaient la permission de faire
prendre dans la forêt de la terre de bruyère, nécessaire à leur travail, qui y
est fort bonne;—mais la liste civile a pris le parti de la réserver pour le
potager de Versailles et pour les pépinières de Trianon,—tandis que les
jardiniers marchands sont obligés de la tirer de Palaiseau et de Saint-Léger,
c’est-à-dire de quatre à cinq lieues de là.
Les jardiniers ont un si grand besoin de feuilles d’arbres ramassées et de
mousse, qu’ils les payent, l’hiver, huit ou neuf francs par voiture. Il y a
quelques années, les pépiniéristes ont fait une pétition pour demander la
réforme de quelques abus, et on leur a supprimé la permission de ramasser
des feuilles,—permission qui, du reste, leur a été rendue depuis.
Je sais bien,—monsieur le comte,—qu’Abdalonyme était jardinier avant
d’être roi,—et que Dioclétien le fut après avoir été maître du monde;
Mais je ne vois aucun prince qui ait cumulé ces deux professions de roi
et de maraîcher, et qui les ait exercées simultanément.
J’en excepterais un duc de Pirmasentz, ville de soixante-dix-huit
maisons, dont j’ai raconté l’histoire dans un livre appelé Einerley, et qui
cultivait des œillets,—mais celui-là ne les vendait pas.
Croyez-vous, monsieur le comte, qu’il soit bien utile à la gloire du roi
Louis-Philippe qu’il soit le premier à donner ce spectacle?
Voici ce que me rapporte une guêpe, qui a passé les barrières et qui est
allée du côté de Versailles pour voir si le printemps s’avance.
On lit dans un journal, sous la rubrique de Calais: «L’éclipse de
lune a été la cause bien involontaire de l’échouement d’un de nos bateaux
pêcheurs.»
Voici des choses un peu fortes que me dit une guêpe nouvellement
enrôlée dans mes escadrons.—Si quelqu’un avait des preuves à me donner
contre les assertions de ma nouvelle recrue,—je les accepterais et les
enregistrerais avec plaisir,—ainsi que je le fais et le ferai toujours chaque
fois qu’on me démontre ou me démontrera que j’ai été ou que j’aurai été
mal informé.
Le maréchal Soult nous a appris entre autres choses, dans la séance du
22 janvier, qu’il avait gagné la bataille de Marengo tout en défendant
Gênes.
Cette victoire, si opiniâtrément disputée par les Autrichiens au premier
consul Bonaparte, ne lui est pas moins vivement contestée par les Français.
Du vivant de l’Empereur, certaines gens prétendaient que c’était le
général Desaix qui avait gagné la bataille. Le fait est qu’il y fut tué.
Sous la Restauration, feu le duc de Valmy passait pour avoir gagné la
bataille par une certaine charge de cavalerie.
Voici maintenant M. le maréchal Soult qui nous apprend qu’à lui seul est
dû l’honneur de cette victoire, de même que celle d’Austerlitz.
Il y a trois ans, M. le maréchal Clauzel, dans ses Explications, apprit à
toute la France qu’il avait gouverné Raguse et couvert de belles routes toute
la côte dalmate. Il se vantait, en outre, d’avoir amené son corps d’armée à
l’Empereur sur le champ de bataille de Wagram.
Vérification faite, il se trouva que tout ce que ledit maréchal Clauzel
croyait avoir fait appartenait en propre au maréchal Marmont, duc de
Raguse, sous les ordres duquel M. Clauzel était alors employé.
Pendant quinze ans le maréchal Macdonald s’est laissé appeler par tous
les journaux vainqueur de Raab.
Cette bourde a été reproduite dernièrement par M. Ph. de Ségur dans un
éloge qu’il a prononcé en Chambre des pairs.
Le fait est que la bataille de Raab a été gagnée par le prince Eugène
Beauharnais, qui commandait l’armée d’Italie; à la vérité, le maréchal
Macdonald, alors général de division, servait sous les ordres de ce prince,
mais il n’assista même pas à cette bataille, étant avec sa division à une
journée en arrière.
Toutes ces choses pourraient bien devenir de l’histoire si la critique
contemporaine n’y met bon ordre. Celui de nos maréchaux qui vivra le plus
longtemps finirait par avoir gagné, à lui tout seul, toutes les batailles de la
Révolution et de l’Empire.
Nous avons déjà parlé des avantages incontestables que procurent
au pays les fréquents changements de ministère dont nous jouissons depuis
quelques années. A peine les administrations et les institutions ont-elles
commencé à recevoir une impulsion dans une ligne quelconque,—qu’un
autre ministère vient changer la direction pour une autre, qui sera encore
changée avant qu’on ait atteint aucun but.
Il y a encore d’autres agréments attachés à ce système, agréments qu’il
n’est peut-être pas mauvais de dévoiler. Les ministres sortants—
ressemblent à ces marins—dans une scène fort bien décrite par M. Sue,—
qui, après dîner, s’amusent à jeter, par les fenêtres, la vaisselle et les
meubles. On pourrait encore les comparer à ces marchandes de salade de la
halle, qui, chassées à une certaine heure par les sergents de ville,—offrent, à
un vil prix, le reste de leur marchandise.
Au moment du départ, toutes les complaisances, toutes les amitiés, tous
les dévouements, sont admis à une grande curée de tout ce qui reste à la
disposition des ministres: les croix, les emplois, l’argent, sont distribués à la
manière des comestibles aux anciennes fêtes publiques.—Pendant que le
ministre s’en va,—on l’arrête sur l’escalier, dans la cour,—à la porte du
ministère,—il est encore un peu ministre: on lui fait signer, signer, signer.
Tout cela se fait avec tant de confusion, qu’il est arrivé quelquefois, par
hasard, et sans mauvaise intention, que l’on ait commis quelque mesure
utile, que l’on se soit laissé aller à décerner une récompense méritée. Le
plus sûr est pourtant de ne pas s’y fier.
Il est un reproche qu’on me fait fréquemment.—Je reçois une lettre ce
matin qui est la soixantième, contenant à peu près les mêmes choses; je
réponds aux soixante lettres et aux soixante reproches à la fois: Pourquoi
n’avez-vous pas de couleur?
Il faut que j’explique ce qu’on appelle,—en journalisme,—avoir une
couleur. Quand vous voulez avoir une couleur,—je vous fais grâce des
nuances,—vous annoncez que vous êtes pour ou contre le pouvoir.
Si vous êtes pour le pouvoir, de ce moment vous êtes enchanté de tout ce
qu’il fait et de tout ce qu’il fera; s’il pleut, vous en rendez grâce à sa haute
sagacité, à sa paternelle prudence. Si le pouvoir dit: «Comment vous portez-
vous?» vous citez le mot charmant; les cheveux de M. Bugeaud vous
paraissent blond cendré; M. Fulchiron est un poëte distingué. Le pouvoir
ferait guillotiner la moitié de la nation, brûler les moissons, rôtir les enfants,
que vous n’en feriez pas moins l’éloge de son inépuisable bonté.—Si vous
êtes dans l’opposition, tout ministre est un voleur, un traître. Le roi ne peut
se promener dans son jardin sans que vous vous croyiez obligé de crier à la
tyrannie et à l’arbitraire. A tout homme qui éprouve des contrariétés de la
part de la police vous êtes obligé de tresser des couronnes. Le
gouvernement répandrait l’abondance, la paix, l’union, dans toute la France,
que ce n’en serait pas moins pour vous un gouvernement absurde, ennemi
du pays, et qui pèserait sur la France.
Ne pas avoir de couleur, c’est ne suivre de règle que le sens
commun, c’est blâmer le mal, louer le bien, rire du ridicule, quel qu’en soit
l’auteur; c’est garder entre tous les partis du bon sens, de la bonne foi, du
jugement et de l’esprit.
Grande nouvelle: les journaux nous annoncent que nous avons enfin
un poëme épique, la divine épopée.—Il paraît que c’est une chose fort
agréable et fort utile que d’avoir un poëme épique,—car dans tous les temps
on a agité cette question: «Avons-nous un poëme épique?» Tous les vingt
ans—il en paraît un nouveau,—et on dit alors: «La France n’avait pas de
poëme épique.»
Si un poëme épique se compose de quelques milliers de vers très-
ennuyeux, nous avions la Henriade de Voltaire, dont la France—ce me
semble—aurait pu se contenter.
J’ai toujours entendu dire que la Henriade est un poëme épique;—un
poëme épique est une chose dont on est fier, mais qu’on ne lit pas.
Je ne trouve pas que le peuple français,—en cette circonstance,—montre
un enthousiasme suffisamment frénétique.
On a cependant fait beaucoup d’annonces pour apprendre audit peuple
français l’événement qui devait le combler de joie.
Mais—entends donc,—peuple français, entends donc—la bonne
nouvelle.—Peuple français, tu as un poëme épique;—la nature non plus ne
se met guère en harmonie avec la circonstance,—l’hiver recommence,—les
sureaux et les chèvrefeuilles, qui étaient tombés dans le piége que leur
tendaient quelques rayons de soleil, ont vu sécher leurs premières feuilles
déjà sorties,—absolument comme si nous n’avions pas de poëme épique;—
mais qu’est-ce que cela te fait,—peuple français?—tu as un poëme épique;
—du reste, c’était le vrai moment d’en avoir un.
On s’occupe beaucoup à la Chambre et dans les journaux de la loi
sur la propriété littéraire.—On a déjà prononcé beaucoup de discours, on a
écrit de longues pages, et nous ne sommes pas au bout. Il y a quelques
années déjà,—au milieu d’une discussion sur le même sujet,—j’avais
proposé une loi, qui a été jugée, en ce temps-là, par les meilleurs esprits, si
simple, si raisonnable, qu’on n’y a pas trouvé la moindre objection. Ce
projet de loi, le voici,—j’ai lu tout ce qu’on a dit, tout ce qu’on a écrit sur la
question; il répond à tout:
ARTICLE UNIQUE. La propriété littéraire est une propriété.
Et cette propriété, une fois reconnue, rentrerait dans toutes les lois et
ordonnances relatives à la propriété en général. Cela est simple,—cela est
facile à trouver,—ce qui n’empêche pas que cela ne sera pas pris en la
moindre considération.
On a frappé de ridicule l’ancien amour romanesque,—qui attendait
cinq ans un regard,—cinq autres années un ruban,—cinq autres années un
baiser sur la main, et n’arrivait à recevoir le prix de son douloureux martyre
que lorsque ce prix était considérablement avarié et décrépit.—Cependant
l’amour ressemble beaucoup à un jardin au bout duquel on arriverait en
trois pas, si le chemin à faire n’était prolongé en une foule de petites allées
tournant capricieusement, fleuries et embaumées.
La nature avait donné à l’homme sa femelle, comme à tous les animaux,
—c’est l’homme qui a inventé la femme,—et c’est sa meilleure invention.
En ce temps-là, les romans et les romances ne vous peignaient que des
Amadis ténébreux et des Galaors mélancoliques—chantant leur martyre
dans leur délire, etc.
Aujourd’hui on a changé cela comme bien d’autres choses; les romans et
les romances ne représentent plus que des femmes méprisées,—se roulant,
se tordant aux genoux d’un homme,—ce qui est assez laid.
La même manie de changement qui a fait mettre sur les adresses le
numéro avant la rue,—a amené quelque chose de plus grave et de plus
satisfaisant pour la vanité des gens;—autrefois, quand on perdait un parent,
—la formule des lettres de faire part était celle-ci:
«Nous avons l’honneur de vous faire part de la perte de M..., etc.»
Puis, au bas de la lettre, en caractères plus petits, on ajoutait: «De la part
de M. et de M...»
Il est évident que le mort jouait le premier rôle et que les parents,
simples comparses,—n’avaient que le petit plaisir collectif et indirect
d’étaler les titres et les décorations de leur mort. Cela ne pouvait durer ainsi,
et on a changé la formule; on écrit aujourd’hui: «M..., chevalier de... de... et
de...; M. le président de..., madame la marquise de..., etc.;» puis, quand il
n’y a plus ni noms, ni titres, on ajoute au bas: «Ont l’honneur de vous faire
part de la mort de...»
Ce qui me paraît peu décent;—mais de ce temps-ci tout le monde veut
tellement paraître, qu’on est jaloux de l’attention posthume qu’usurpe le
pauvre mort.
J’ai sous les yeux un exemple curieux de ce nouvel usage. Il s’agit de la
mort de M. le baron Bl*** de B***, mort à Versailles.—Eh bien! si, averti
par l’encadrement noir de la lettre, vous voulez savoir lequel de vos amis
vous avez à regretter, il faut lire d’abord dix-sept noms suivis chacun de
deux à trois lignes de titres et de décorations en petit texte, avant d’arriver
au nom du mort, que rien ne sépare des noms de ses parents, afin qu’il soit
impossible de le lire sans avoir préalablement lu les autres. Mais il s’est
glissé dans cette lettre une singulière erreur:—on a confondu l’ancienne et
la nouvelle formule, et on s’y est considérablement embrouillé.
Dans l’ancienne formule—on mettait: «De la part de MM. tels et tels, de
mesdames telles et telles,—ses frère,—cousin,—neveu,—nièce, etc.»
Dans la nouvelle,—on doit mettre: «MM. et mesdames tels et telles vous
font part de la mort de M. Bl***de B***, leur frère, cousin, oncle, etc.»
Dans la lettre de faire part de M. Bl*** de B***, on a confondu les deux
formules,—et on dit: «MM. et mesdames tels et telles vous font part de la
mort de M. Bl*** de Bl***,—leur père, beau-père, etc.,—nièce et petite
nièce.»
De telle sorte que ce vieillard de quatre-vingt-trois ans se trouve, dans la
lettre qui annonce sa mort, être la nièce et la petite-nièce de mesdemoiselles
trois et quatre étoiles.
Je viens de lire dans un journal que feu M. de Quélen, l’archevêque
de Paris,—s’était adjoint—je ne sais plus quel prélat,—pour l’aider à
supporter le fardeau de l’épiscopat.—Cela me rappelle que je vois de temps
à autre dans d’autres feuilles et j’entends dire à la tribune—le poids des
affaires publiques,—le faix de la royauté,—etc., etc.
Ces phrases étaient bonnes à la rigueur et pouvaient espérer des dupes
quand il était d’usage de couvrir son ambition et son avidité d’un manteau
d’amour du bien public et de désintéressement;—mais elles sont bien
ridicules aujourd’hui—que l’on joue les plus vilains jeux, cartes sur table.
UN BIENFAITEUR A BON MARCHÉ.—Un homme fort riche se délasse
des travaux qu’il ne fait guère à la Chambre et de ceux qu’il fait faire à son
argent—par des amours cachées; modeste, il n’a pas la prétention d’être
aimé tout à fait pour ses avantages extérieurs. Il ne peut pas, comme César,
donner un royaume à la femme qu’il aime;—il n’a pas de royaume, et, s’il
en avait un, il ne le donnerait pas,—il le prêterait plutôt à quinze pour cent.
La belle, un de ces jours derniers,—était en conversation avec un rival
heureux de son bienfaiteur—lorsque tout à coup la sonnette se fait entendre.
—C’est lui!
M. de *** se trouble.
—N’aie pas peur, mon ami,—je l’aurai bientôt renvoyé: j’ai un moyen.
On cache l’ami dans un cabinet.—Le bienfaiteur arrive:
—J’ai sonné bien longtemps,—dit-il.
—J’étais occupée à mettre en ordre des mémoires;—je dois à tout le
monde,—vous êtes un horrible avare,—vous ne me donnez rien,—je suis
dans la misère.
—Mais, ma bonne...
—J’attends des fournisseurs,—des créanciers.
—Mais...
—Tenez, allez-vous-en,—je ne peux pas supporter votre présence.—
Allez-vous-en,—vous reviendrez demain.
Le bienfaiteur s’en va.—En sortant—il laisse clandestinement sur la
cheminée un billet de mille francs. La belle ne s’en aperçoit pas et le
reconduit—pour être plus certaine de son départ.
M. de ***, qui a vu le geste,—sort de sa cachette,—voit le billet de mille
francs et le met dans sa poche.
—Comment, mon cher ange, dit-il à la déesse,—tu es gênée et tu ne
m’en dis rien;—tu me caches tes chagrins, à moi qui serais si heureux de les
effacer!—mais c’est mal,—c’est très-mal!—Comment,—tu ne pouvais pas
me dire: «J’ai besoin d’argent.» Je suis bien en colère contre toi.—Tiens,
j’ai là un billet de mille francs,—je veux que tu le prennes;—je ne te
pardonnerai qu’à cette condition.
La belle hésite,—sans s’exposer cependant à être prise au mot.—M. de
*** insiste,—fait accepter le billet de mille francs de son rival,—et
s’échappe pour aller conter l’anecdote au foyer de l’Opéra.
M. le marquis de Basincourt, qui pendant les désastres de Lyon a
négligé ses propriétés pour celles des pauvres habitants, qui a sauvé à la
nage la vie de plusieurs personnes en danger,—a distribué de l’argent et du
pain à ceux que l’inondation avait le plus maltraités, a été nommé officier
de la Légion d’honneur.
C’est très-heureux et très-flatteur... pour la croix,—et c’est tout au plus si
elle le mérite.
A la Chapelle-Saint-Denis, le cimetière est tenu par un homme qui
n’a d’autre charge que d’enterrer les corps qui lui arrivent.—Il n’a pas de
registres, et, conséquemment, ne peut donner aucun renseignement.—Une
fois qu’il a mis ses morts en terre, tout est fini pour lui, et, à ce qu’il croit,
pour les autres, tellement que l’autre jour il trouvait fort mauvais la colère
où était un monsieur qui cherchait une fosse sans pouvoir la reconnaître; il
n’a jamais pu la lui indiquer.—Une autre personne, plus favorisée, a été
guidée par lui; mais, comme il ne va lui-même qu’au hasard, il l’a conduite
sur une tombe où était un autre mort que le sien,—ce dont elle ne s’est
aperçue—qu’après une assez considérable effusion de larmes pieuses.
Ce quiproquo de douleur rappelle ce qui se passa à Paris à l’église des
Petits-Pères—à l’époque du choléra:—on prenait les morts dans des
tapissières, où on en entassait une douzaine en ayant soin seulement de
numéroter les cercueils.
Arrivé à l’église, le cocher faisait porter chaque bière pendant quelques
instants dans le chœur.
Allons, nº 1;—les parents du nº 1, venez pleurer votre mort; assez pleuré
le nº 1;—passons au nº 2.
Allons, les parents du nº 2,—finissons-en, nous ne sommes pas ici pour
nous amuser,—dépêchons la douleur,—pleurons un peu vite.
Tout cela alla fort bien jusqu’au moment où on arriva au nº 6:—
comment distinguer le nº 6 du nº 9;—l’un de ces deux chiffres peut être
l’autre renversé.
A qui le mort?—voyons;—eh bien! les parents du nº 6 et les parents du
nº 9;—pleurez ensemble et partons.
Les Français ont eu longtemps un ridicule qu’on retrouve du reste
plus ou moins chez les autres peuples,—c’est la prétention d’être
invincibles.—On en a vu récemment une dernière manifestation lorsque
messieurs les députés s’emportèrent si fort contre M. Bugeaud, qui avait osé
dire que les Français avaient été quelquefois battus dans le commencement
des guerres de la République.
Remarquons en passant, à propos de M. Bugeaud,—que son
discours en faveur de la paix a été récompensé par un commandement
militaire.
Revenons à notre sujet:—la nouvelle prétention des Français est
aujourd’hui d’être humiliés, insultés, foulés aux pieds;—vous avez vu le
gâchis où ont failli nous mettre M. Thiers et les affaires d’Orient;—depuis
ce temps il est impossible qu’un cuisinier anglais fasse une sauce,—qu’un
serf russe coupe un arbre,—sans que les journaux annoncent à la France que
c’est dans l’intention de l’insulter;—les bonnes gens le croient et sont prêts
à crier comme le père du Cid:
C’en est fait,—prends ma vie avec un tel affront,
Le premier dont ma race ait vu rougir son front.

On prend des attitudes abattues,—des airs déshonorés à n’en plus finir.


Dernièrement des carrés de papier (organes de l’opinion publique)
avaient fait croire aux Français que l’on jouait à Londres une pièce
injurieuse pour notre honneur national,—intitulée le Coq gaulois chante,
mais il ne se bat pas.
Les Français se sont indignés, sans penser que pendant quinze ans, en
France, il ne s’est pas joué un seul vaudeville,—où il n’y ait eu un Anglais
bafoué et battu.
Indignation de plus en plus véhémente des carrés de papier,—et par
contre-coup du peuple français.
Pendant ce temps, Victor Bohain,—qui est aujourd’hui à Londres, et qui,
—lorsqu’il demeurait à Paris, n’allait au théâtre que pour y dormir,—s’est
mis à courir les théâtres de Londres, et n’a pu voir ni la pièce en question,
ni rencontrer quelqu’un qui l’eût vue quelque part.
PROGRÈS DE L’ANNONCEP:—On lit dans divers journaux:
«M. Lacordaire prêchera dimanche à Notre-Dame, en habit de
franciscain.»
Cela rappelle beaucoup les affiches des théâtres de province qui
annonçaient que mademoiselle Georges jouerait avec tous ses diamants.
Au bal déguisé de lundi chez la reine, où toutes les femmes étaient
brillantes, on a remarqué madame la duchesse de Nemours, qui était
admirablement belle dans un costume choisi par le roi, qui avait mis tous
ses soins à la rendre encore plus jolie.
Les princes étaient tous fort exactement costumés. On a dansé jusqu’à
cinq heures.
Le lendemain,—le prince de Joinville,—le duc de Nemours—et le duc
d’Aumale—ont demandé à M. L... un bal où ils sont arrivés déguisés, le
premier en débardeur,—le second en hussard,—le duc d’Aumale en marin;
—ils se sont fort amusés,—et se sont laissés aller à mille folies, entre autres
de déchirer les habits de ceux qui n’étaient pas déguisés.—Leur danse a été
si animée, que, dans un établissement public, elle eût inévitablement éveillé
la sollicitude des sergents de ville.—Le duc de Nemours a ôté son habit.—Il
est possible,—comme dit le vieux journal, le Constitutionnel, dans ses jours
de terreurs,—que nous dansions sur un volcan;—mais il faut dire que nous
y dansons beaucoup.
Voici une anecdote que m’a racontée un jour,—en dînant chez notre
***
ami G ,—ce bon général Clary, qui vient de mourir subitement:
Il était lieutenant, et se trouvait à dîner à la campagne avec le général
Lasalle.—Un bourgeois arriva un peu en retard et fort en désordre,—et dit
pour s’excuser qu’il avait mis pour la première fois au cabriolet un cheval
très-vigoureux qu’il avait;—que le cheval s’était emporté, avait rompu les
brancards; que son domestique était blessé, et que c’était un grand hasard si
lui n’avait pas été tué;—que, du reste, il avait donné ordre à son domestique
de reconduire le cheval sans l’atteler.
—Il est donc bien difficile?—demanda le général Lasalle:
—Si difficile—que je considère comme impossible de l’accoutumer
jamais à la voiture.
—Voulez-vous me prêter votre cheval et votre cabriolet pour m’en
retourner à la ville après dîner?
—D’abord, mon cabriolet est brisé,—et, ne le fût-il pas, je ne voudrais
pas vous exposer à un danger que je crois très-grand et inévitable.
—C’est égal, j’y tiens.—Obligez-moi, mon cher, dit le général au maître
de la maison, de me faire avoir un cabriolet.
On veut détourner le général, mais il se montre si décidé, qu’on lui cède.
—Lieutenant Clary, dit-il, voulez-vous m’accompagner?
—Certainement, général.
Après dîner,—on attelle le cheval;—Clary et Lasalle allument chacun un
cigare,—et montent dans le cabriolet après avoir subi de nouvelles
observations.
Le cheval gagnait à la main, et portait le nez au vent.—Le bruit des
roues l’effrayait au point de lui faire faire des bonds convulsifs.—Lasalle,
qui était très-vigoureux,—le maintenait de toutes ses forces.—Bientôt il fut
obligé de tourner chacune des rênes autour de ses mains;—mais on arriva à
une chaussée pavée,—le bruit des roues augmenta;—le cheval devint fou et
s’emporta tout à fait, malgré les efforts de Lasalle.—La situation se trouva
bientôt très-aggravée par cette circonstance qu’il se rencontra une colline à
descendre. «J’avais assez peur,» disait Clary en racontant le fait.
Lasalle me dit: «Faites comme moi.»—Il me donna une des rênes,—il se
mit à tirer sur l’autre de ses deux mains.
Mais bah!—le cheval ne courait que plus fort.
Alors Lasalle me dit froidement: «Rendez-moi la rêne.»—Je la lui
donnai;—il noua les deux ensemble et les jeta par-dessus le tablier du
cabriolet, sur le dos du cheval, croisa les bras et se remit à fumer son cigare,
qui n’était pas éteint,—le mien l’était.—Le cheval alors—n’étant plus gêné,
—se lança à travers la campagne, franchissant les fossés.
—Voulez-vous du feu, Clary?—me dit le général.
Mais à ce moment—le cheval, le cabriolet, Lasalle et moi, fûmes
précipités au fond d’un ravin,—le cheval à moitié mort, le cabriolet brisé,—
moi fort étourdi;—Lasalle, debout,—me répéta: «Voulez-vous du feu?»—
Ma foi,—je rallumai mon cigare, qu’au moment de la chute j’avais
machinalement et convulsivement tenu serré entre mes dents,—et nous
continuâmes la route à pied.
Dans la discussion des fonds secrets, M. Thiers a dit qu’il n’y a plus
à faire que de la politique extérieure,—le tout parce que sa femme ne veut
recevoir que des étrangers, et parce qu’elle a du ruban violet et blanc. Ceci
veut dire que, manquant d’idées pour gouverner et organiser son pays, il
demande à remuer l’Europe pour que le bruit du monde empêche de voir le
trouble de la France.
La gauche,—qui faisait de si longs discours contre les fonds secrets,—
les a votés,—comme un seul homme,—en faveur de M. Thiers,—les
marchande cette fois-ci à son successeur.—On n’est violée qu’une fois, ô
gauche! et il est ridicule de jeter de si grands cris à la seconde.
Éloquence de M. Taschereau: «Ah!—oh!—hi!—han!—je demande
l’appel nominal.»—(A propos de l’armée): «A bas les sinécures!»—A M.
Guizot: «Allez à Gand!»—A M. Soult: «Vous n’étiez pas au siége de
Troie.»
Le rapport des fortifications traîne en longueur à la Chambre des
pairs, c’est déjà quelque chose que cette lenteur, comparativement à la
pétulance de l’autre Chambre.
Nous avons cependant la douleur de répéter ici—que la coalition
des Tuileries et du National l’emportera,—que les ambassadeurs, les
généraux, les hommes dépendants, et tous ceux qui veulent le devenir,—se
joindront pour voter le projet de loi—à une portion de la Chambre très-
prononcée contre le projet en paroles, et qui se laissera attendrir. On craint
la faiblesse de MM. Pasquier et Portalis.
M. Ancelot a été élu à l’Académie;—cette élection est entachée de
vaudeville,—il faut l’avouer.
M. de Chateaubriand, qui n’écrit plus une ligne sans parler de sa
mort et de sa sépulture,—semble s’être fait le saule pleureur de sa propre
tombe.
La direction de l’Opéra, qui n’est que l’application du 1er mars à
l’art dramatique, est menacée d’un changement de ministère.—C’est vers le
1er juin qu’aura lieu cette révolution;—on remarque déjà qu’il n’y a plus
que la Favorite et plus de répertoire.
Avril 1841.
Histoire d’un monsieur auquel il manquait trente-quatre sous.—Sur la propriété littéraire.
—M. Berville.—M. Chaix-d’Est-Ange.—M. Lherbette.—M. Durand de Romorantin.—
M. Hugo.—M. de Lamartine.—Histoire de M. M*** et d’un commissaire de police.—Un
mot d’ami sur M. Villemain.—De la valse à deux temps.—Des miracles du puits de
Grenelle.—Une histoire d’un voleur.—Sur les fortifications.—A quoi tient un vote.—M.
Thorn.—Les fleurs des critiques et des romanciers, et, en particulier, de quelques fleurs
de M. Eugène Sue.—Un œillet.—Un mot d’amie.—Un distique sur un avocat.—De la
tyrannie et de l’inviolabilité de MM. les comédiens.—La vérité sur mademoiselle Eissler
aux États-Unis.—Le timbre, les Guêpes et les cachemires.—De l’éloquence du Palais.—
M. Léon Bertrand.—Deux nouvelles étoffes.—L’exposition de peinture.

Pour cette fois, je commence bien.—J’ai envoyé mon sommaire aux


journaux, et on me fait remarquer que je suis coupable d’un délit.—La loi
est formelle.
J’ai dit trente-quatre sous, j’en ai le droit dans mon volume; mais, dans
les annonces, je dois dire un franc soixante-dix centimes.—Dans un pays où
quatre cents hommes passent leur vie à faire des lois avec d’autant plus
d’empressement que, pour les uns,—leur âge, leur fortune et leur position
ne les soumettent pas aux lois qu’ils font;—que pour les autres,—tous
avocats, toute loi enfante des procès,—il est impossible d’aller de l’église
Notre-Dame-de-Lorette au boulevard sans avoir contrevenu à deux ou trois
lois et à cinq ou six ordonnances.
Ainsi, si un libraire,—par fantaisie,—s’avisait de mettre dans les
annonces qu’il ferait d’un livre de M.*** ces deux vers qui se trouvent dans
l’ouvrage:
Le soleil se levait dans une vapeur bleue,
Au bout d’un chemin vert long de plus d’une lieue.

Il voudrait bien dire:


Le soleil se levait dans une vapeur bleue,
Au bout d’un chemin vert long de trois mille neuf cent quatre-vingt-
dix-huit mètres.

Autrement,—ceci n’est pas une plaisanterie,—il peut être poursuivi et


condamné.
J’ai quelque raison de m’alarmer à ce sujet,—parce que la semaine ne
m’a pas été favorable.—J’ai été condamné à la prison pour la garde
nationale, et au timbre par je ne sais quel tribunal.—Par suite de quoi, mon
premier numéro sera timbré.—Avec quelque pureté de cœur que je me
réveille chaque jour, j’ai, depuis quelque temps, bien du mal à me coucher
innocent.
Parlons de l’homme aux trente-quatre sous:—l’homme aux trente-
quatre sous (vieux style) est M. Pelletier-Dulas,—élu député à Château-
Chinon, dont l’élection a été annulée par la Chambre à cause qu’il s’en faut
de un franc soixante-dix centimes—qu’il paye le cens d’éligibilité.
Ce monsieur a paru plus qu’assez audacieux de s’aller ainsi glisser
en la compagnie de gens qui payent trente-quatre sous de plus que lui;—on
l’a renvoyé avec ses pareils, c’est-à-dire avec des gens qui payent trente-
quatre sous de moins que M. Auguis.—Si M. Auguis lit les Guêpes, il doit
rire dans sa barbe de ce que je le prends ici pour exemple.
Toujours est-il que M. Pelletier-Dulas,—qui, avec trente-quatre
sous de plus,—eût fait des lois pour les autres, s’en est retourné à Château-
Chinon subir les lois qu’il plaira de faire à ceux qui ont trente-quatre sous
de plus que lui.—Et, s’il veut parler en public, il sera obligé de se faire
membre de quelque société philanthropique ou scientifique, ou patriotique
ou religieuse,—toutes ayant divers prétextes,—mais n’ayant qu’un seul et
même but,—ainsi que j’ai déjà eu occasion de le dénoncer, à savoir: de
monter sur quelque chose et de parler devant d’autres gens.
C’est pourquoi—je suis décidé à ne plus laisser faire cette vieille
plaisanterie usée sur la loquacité des femmes—à une époque où les hommes
feignent une foule de goûts, de vertus, de vices, de sciences, de missions, de
devoirs, etc., pour se rassembler dans des endroits et y parler d’abord,
chacun à son tour, au commencement des séances, puis tous à la fois, pour
ne pas perdre de temps à écouter.
DE LA PROPRIÉTÉ LITTÉRAIRE.—Une des plus grandes preuves de
l’amour de la parole dont sont possédés les gens en ce temps-ci est sans
contredit—la ridicule discussion sur la propriété littéraire.
Je commencerai par dire que je suis aussi désintéressé dans la question
que M. Lherbette ou M. Chaix-d’Est-Ange,—qui n’écrivent pas.
Si j’avais eu besoin ou désir d’argent,—j’aurais fait un tout autre métier
que celui de poëte,—métier auquel je ne demande que l’indépendance,—la
paresse et la dignité,—acceptant comme argent trouvé—celui qui me
revient de mes vers ou de ma prose.
De quoi je donnerai pour preuve,—seulement en ce qui regarde les
Guêpes,—que depuis un an et demi que je les publie—je n’ai jamais
prétendu tirer aucun bénéfice des reproductions qu’en ont faites les
journaux de Paris et surtout de la province,—ne suivant pas en cela
l’exemple de mes confrères de la Société des gens de lettres,—Société sur
laquelle je me suis suffisamment expliqué—dans mon volume du mois de
mars 1840;
Que j’ai refusé formellement de joindre à mon volume quelques pages
d’annonces,—pour lesquelles on m’offrait d’assez fortes sommes,—ce que
je ferai seulement à prendre du mois prochain,—pour m’aider à payer le
timbre, auquel j’aurai à donner six cents francs par mois,—ce que je serais
assez embarrassé de faire sans cet expédient.
J’avais proposé une loi,—claire et simple suffisamment: La
propriété littéraire est une propriété.
M. de Lamartine et quelques bons esprits étaient de mon avis;—mais ils
n’ont pas osé proposer à la Chambre quelque chose d’aussi raisonnable, et
ils ont pris un terme de cinquante ans, qui a été repoussé.
On ne peut,—disait-on, assimiler les œuvres de l’esprit et de
l’intelligence aux propriétés grossières et matérielles;—ces œuvres
appartiennent à la société,
Tudieu! messieurs, quel respect aujourd’hui et quelle humilité!—cela
ressemble beaucoup à l’action de Jacques Clément, qui se met à genoux
pour mieux poignarder Henri III.
La société,—qu’entendez-vous par ce mot? Qu’est-ce que la société
a en commun?—La société qui profitera des œuvres de l’esprit, ce sera,
dans vingt ans,—un libraire,—un marchand de quelque chose;—ce sera un
Lebigre ou un Ledentu d’une autre époque.—Hélas!—hélas!—mes bons
messieurs de la Chambre,—je vous le dis, en vérité,—c’est une loi agraire
que vous nous proposez là;—c’est un partage des œuvres de l’intelligence;
—et,—je suis forcé de le faire remarquer, messieurs mes représentants,—
j’ai toujours vu que les gens qui criaient le plus fort pour le partage étaient
ceux qui mettaient le moins à la masse.—Les lois agraires n’ont jamais, a
aucune époque que je sache,—été présentées par les gros capitalistes et les
riches propriétaires.—Je ne pense pas que M. Roy—ou M. de Boissy—
soient fort partisans d’une loi agraire,—messieurs.—C’est un
rapprochement qui n’est peut-être pas très-heureux pour vous, messieurs.
Je l’ai déjà dit,—ce n’est pas la chose en elle-même qui me frappe;
—pour moi, je n’ai jamais demandé beaucoup d’argent à la littérature,—et
je puis, quand je voudrai, gagner ma vie à deux ou trois autres métiers que
j’ai appris.—Je suis jardinier et laboureur, et je compte pour un bon
travailleur sur les bateaux de pêche d’Étretat.
Mais je prends en grande pitié—ces pauvres gens qui s’intitulent
conservateurs,—et auxquels on a tant de fois demandé déjà avec raison:
«Mais que conservez-vous donc?»
Voici que l’on attaque la propriété—par un de ses côtés, il est vrai, les
moins respectés;—mais, quoi qu’il en soit,—c’est toujours la propriété.
Et il ne s’est pas trouvé, à la Chambre, un homme pour dire:
«Messieurs,—il n’y a pas plusieurs sortes de propriété;—la question qui
nous est soumise n’existe pas,—la propriété littéraire est garantie par les
lois, déjà au moins assez nombreuses, sur la propriété.—Nous n’avons rien
à faire;—si nous faisons une loi sur la propriété littéraire, il n’y a pas de
raison pour que nous ne fassions pas une loi spéciale sur toutes les formes
de la propriété;—et je vous propose une loi—sur chacune des formes que
voici:
»Sur la propriété des chapeaux;
Idem melons cantaloups;
Idem maraîchers;
Idem abricots;
Idem prunes;
Idem pêches;
Idem —à l’eau-de-vie;
Idemde l’habit vert de M. Auguis.»
Accordez, messieurs, aux œuvres de l’esprit—l’admiration ou le
mépris que vous voudrez,—mais, comme propriété, je n’admets ni
l’emphase de votre éloge hypocrite,—ni votre dédain superbe; les deux vers
dont je viens de trouver la dernière rime—m’appartiennent juste et sans
aucune différence comme la planche appartient au menuisier qui vient de la
raboter.
Il y a un monsieur payant trente-quatre sous de plus que M.
Pelletier-Dulas, je retrouverai son nom,—je l’espère.—Ceux qui liront les
Guêpes plus tard et qui y verront l’histoire de ce temps-ci—ne me
pardonneraient pas de ne leur avoir pas conservé ce nom.
Ledit monsieur a remarqué—que les poëtes avaient plus de talent quand
ils étaient plus pauvres,—et qu’il n’y avait conséquemment pas lieu à
garantir leurs propriétés, ni à assurer leur fortune.
C’est absolument—comme les huîtres que l’on fait jeûner pour qu’elles
soient meilleures à manger;—comme les pauvres volatiles auxquels on
crève les yeux pour qu’ils engraissent plus vite;—comme les carpes que
l’on fait cuire toutes vivantes pour augmenter leur saveur.
Pourquoi,—ô mon bon monsieur! pendant que vous y étiez,—
n’avoir pas rédigé la chose en un petit aphorisme,—comme celui de la
Cuisinière bourgeoise?
«Le lapin aime être écorché vif, le lièvre préfère attendre.»
«Le poëte aime mourir de faim, le député préfère manger.»
Mais, messieurs les conservateurs, si vous aviez, faute de mieux,
conservé un peu de sens et de raison—au milieu de la folie universelle,—
n’auriez-vous pas remarqué quels terribles arguments vous donnez à
l’émeute?
Si moi, par exemple, je croyais et tenais à ma propriété littéraire,—que
répondriez-vous à ces paroles que je vous dirais:
«Comment! vous,—monsieur un tel,—vous me niez la propriété des
œuvres de mon esprit, de ce que j’ai créé,—de ce qui n’existait pas avant
moi!—et vous voulez que je reconnaisse votre droit et celui de vos
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like