← Bilinen Hatalar

regexp.c Eklendi, regexp.h Unutuldu

BusyBox Eksik Dosya 11 commit etkilendi 1999-10-22 → 1999-10-26

Ne Oldu ve Neden

BusyBox henüz 11 günlükken (ilk commit 5 Ekim 1999), Erik Andersen gerçek regex desteği eklemek için elvis-tiny 1.4 editöründen (Henry Spencer'ın klasik regexp(3) kütüphanesinin bir türevi) regexp.c dosyasını uyarladı. Bu dosya #include "internal.h" ve #include "regexp.h" ile başlıyordu, ve NSUBEXP makrosuyla struct regexp tipini bu ikinci başlıktan bekliyordu.

Ama commit'i incelediğinde göreceğin gibi: regexp.h bu commit'e hiç eklenmedi. Sadece regexp.c geldi. glibc'nin o dönemki kendi <regexp.h>'ı (POSIX'in eski, "withdrawn" V8 uyumluluk arayüzü) farklı semboller sağlıyordu, NSUBEXP/struct regexp onda da yoktu — yani derleme hiçbir sistemde başarılı olamazdı.

Eric Andersen
Hatayı açan commit: Eric Andersen
@ErikBAndersen · 1999-10-22
aa0765e11 — Added regexp support, fixed Changelog.

Nasıl Düzeltildi

4 gün sonra, 26 Ekim 1999'da Erik "Stuf" başlıklı (BusyBox'ın ilk yıllarında commit mesajları genelde bu kadar kısaydı) bir commit'te nihayet kendi regexp.h'ını ekledi: NSUBEXP'i 10 olarak tanımlayan ve struct regexp { char *startp[NSUBEXP]; char *endp[NSUBEXP]; ... } içeren, tamamen BusyBox'a özel bir başlık dosyası (sash projesinden esinlenilmiş).

Bu, "unuttum, birkaç gün sonra ekledim" tarzı klasik bir eksik-dosya commit'i — günümüzde git add -A ya da CI bunu anında yakalardı, ama 1999'da yerel diskte çalışıp tek tek dosya ekleyerek commit atmak yaygındı.

Eric Andersen
Düzelten commit: Eric Andersen
@ErikBAndersen · 1999-10-26
c8fdb5638 — Stuf

Düzeltmenin Diff'i

Aşağıda düzeltme commit'inin gerçek diff'i var — dosya dosya gezinebilirsin.

regexp.h+49 -0
@@ -0,0 +1,49 @@
+/*
+ * Busybox regexp header file
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
+ * Permission has been granted to redistribute this code under the GPL.
+ *
+ */
+#ifndef _REGEXP_H_
+#define _REGEXP_H_
+
+
+
+
+#define NSUBEXP 10
+typedef struct regexp {
+ char *startp[NSUBEXP];
+ char *endp[NSUBEXP];
+ int minlen; /* length of shortest possible match */
+ char first; /* first character, if known; else \0 */
+ char bol; /* boolean: must start at beginning of line? */
+ char program[1]; /* Unwarranted chumminess with compiler. */
+} regexp;
+
+
+
+extern regexp *regcomp(char* text);
+extern int regexec(struct regexp* re, char* str, int bol, int ignoreCase);
+extern void regsub(struct regexp* re, char* src, char* dst);
+
+extern int find_match(char *haystack, char *needle, int ignoreCase);
+
+#endif
+
+

Etkilenen Commit'lerden Örnekler