style: enforce webkit style for plugins
$ clang-format -style=webkit -i */.c $ clang-format -style=webkit -i */*/.c
This commit is contained in:
parent
ec97a8f3f3
commit
3483af0f0f
|
@ -1,6 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "str_replace_start.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
void str_init(char* str, int n)
|
||||
{
|
||||
for(int i = 0; i < n; i++)
|
||||
for (int i = 0; i < n; i++)
|
||||
str[i] = ' ';
|
||||
str[n] = '\0';
|
||||
} // could also use <https://manpages.ubuntu.com/manpages/impish/man3/strinit.3pub.html>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG false
|
||||
|
||||
|
@ -16,12 +16,14 @@ int str_replace_start(const char* string, const char* target, const char* replac
|
|||
int l2 = strlen(target);
|
||||
int l3 = strlen(replacement);
|
||||
int l4 = strlen(output);
|
||||
if(DEBUG) printf("%d,%d,%d,%d\n", l1, l2, l3, l4);
|
||||
if (DEBUG)
|
||||
printf("%d,%d,%d,%d\n", l1, l2, l3, l4);
|
||||
// if(DEBUG) printf("%s,%s,%s,%s\n", string, target, replacement, output);
|
||||
|
||||
if((l4 < (l1 - l2 + l3)) || l4 < l1 ){
|
||||
if ((l4 < (l1 - l2 + l3)) || l4 < l1) {
|
||||
// Not enough memory in output string.
|
||||
if(DEBUG) printf("String not long enough.\n");
|
||||
if (DEBUG)
|
||||
printf("String not long enough.\n");
|
||||
return 1;
|
||||
}
|
||||
/* else if(l1 < l2){
|
||||
|
@ -30,29 +32,31 @@ int str_replace_start(const char* string, const char* target, const char* replac
|
|||
strcpy(output, string);
|
||||
} */
|
||||
else {
|
||||
if(DEBUG) printf("Looking for a match for %s in %s.\n", target, string);
|
||||
if (DEBUG)
|
||||
printf("Looking for a match for %s in %s.\n", target, string);
|
||||
int match = true;
|
||||
for(int i=0; i<l2; i++){
|
||||
if(string[i] != target[i]){
|
||||
for (int i = 0; i < l2; i++) {
|
||||
if (string[i] != target[i]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(match){
|
||||
if(DEBUG) printf("Found match.\n");
|
||||
for(int i=0; i<l3; i++){
|
||||
if (match) {
|
||||
if (DEBUG)
|
||||
printf("Found match.\n");
|
||||
for (int i = 0; i < l3; i++) {
|
||||
output[i] = replacement[i];
|
||||
}
|
||||
int counter = l3;
|
||||
for(int i=l2; i<l1; i++){
|
||||
for (int i = l2; i < l1; i++) {
|
||||
output[counter] = string[i];
|
||||
counter++;
|
||||
}
|
||||
output[counter] = '\0';
|
||||
return 2; // success
|
||||
}
|
||||
else {
|
||||
if(DEBUG) printf("Did not find match.\n");
|
||||
} else {
|
||||
if (DEBUG)
|
||||
printf("Did not find match.\n");
|
||||
strcpy(output, string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "../libre_redirect.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(){
|
||||
int main()
|
||||
{
|
||||
char uri[] = "https://reddit.com/r/blah";
|
||||
|
||||
int l = LIBRE_N + strlen(uri) + 1;
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define READABILITY_N 85133 + 1000
|
||||
|
||||
void read_readability_js(char* string){
|
||||
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/plugins/readability/readability.js", "r");
|
||||
void read_readability_js(char* string)
|
||||
{
|
||||
FILE* fp = fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/plugins/readability/readability.js", "r");
|
||||
if (!fp) { // fp is NULL, fopen failed
|
||||
fprintf(stderr, "Failed to open file\n");
|
||||
string=NULL;
|
||||
string = NULL;
|
||||
return;
|
||||
}
|
||||
int i=0;
|
||||
int i = 0;
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF){
|
||||
while ((c = fgetc(fp)) != EOF) {
|
||||
string[i++] = c;
|
||||
}
|
||||
string[i]='\0';
|
||||
string[i] = '\0';
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define STYLE_N 1393 + 1
|
||||
|
||||
void read_style_js(char* string){
|
||||
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/plugins/style/style.js", "r");
|
||||
void read_style_js(char* string)
|
||||
{
|
||||
FILE* fp = fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/plugins/style/style.js", "r");
|
||||
if (!fp) { // fp is NULL, fopen failed
|
||||
fprintf(stderr, "Failed to open file\n");
|
||||
string=NULL;
|
||||
string = NULL;
|
||||
return;
|
||||
}
|
||||
int i=0;
|
||||
int i = 0;
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF){
|
||||
while ((c = fgetc(fp)) != EOF) {
|
||||
string[i++] = c;
|
||||
}
|
||||
string[i]='\0';
|
||||
string[i] = '\0';
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user