GooString: remove cmpN
diff --git a/goo/GooString.h b/goo/GooString.h
index 55144b4..40df888 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -232,9 +232,7 @@
// Compare two strings: -1:< 0:= +1:>
int cmp(const GooString *str) const { return compare(*str); }
int cmp(const std::string &str) const { return compare(str); }
- int cmpN(GooString *str, int n) const { return compare(0, n, *str); }
int cmp(const char *sA) const { return compare(sA); }
- int cmpN(const char *sA, int n) const { return compare(0, n, sA); }
// Return true if strings starts with prefix
using std::string::starts_with;
diff --git a/poppler/CurlPDFDocBuilder.cc b/poppler/CurlPDFDocBuilder.cc
index 8cafba1..ef453b8 100644
--- a/poppler/CurlPDFDocBuilder.cc
+++ b/poppler/CurlPDFDocBuilder.cc
@@ -39,7 +39,7 @@
bool CurlPDFDocBuilder::supports(const GooString &uri)
{
- if (uri.cmpN("http://", 7) == 0 || uri.cmpN("https://", 8) == 0) {
+ if (uri.starts_with("http://") || uri.starts_with("https://")) {
return true;
} else {
return false;
diff --git a/poppler/LocalPDFDocBuilder.cc b/poppler/LocalPDFDocBuilder.cc
index 72b277b..559fb38 100644
--- a/poppler/LocalPDFDocBuilder.cc
+++ b/poppler/LocalPDFDocBuilder.cc
@@ -21,7 +21,7 @@
std::unique_ptr<PDFDoc> LocalPDFDocBuilder::buildPDFDoc(const GooString &uri, const std::optional<GooString> &ownerPassword, const std::optional<GooString> &userPassword)
{
- if (uri.cmpN("file://", 7) == 0) {
+ if (uri.starts_with("file://")) {
std::unique_ptr<GooString> fileName = uri.copy();
fileName->del(0, 7);
return std::make_unique<PDFDoc>(std::move(fileName), ownerPassword, userPassword);
@@ -32,7 +32,7 @@
bool LocalPDFDocBuilder::supports(const GooString &uri)
{
- if (uri.cmpN("file://", 7) == 0) {
+ if (uri.starts_with("file://")) {
return true;
} else if (!strstr(uri.c_str(), "://")) {
return true;
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 2327697..8f62cca 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -861,7 +861,7 @@
}
// be careful not to overwrite the input file when the output format is PDF
- if (pdf && fileName->cmpN("http://", 7) != 0 && fileName->cmpN("https://", 8) != 0) {
+ if (pdf && !fileName->starts_with("http://") && !fileName->starts_with("https://")) {
fprintf(stderr, "Error: an output filename or '-' must be supplied when the output format is PDF and input PDF file is a local file.\n");
exit(99);
}