After running uncrustify I want no line to be longer than, say, 80 characters. How do I set the maximum length of a line in the uncrustify config file?
Add a section like this to your config file. It does not guarantee to get all lines below the specified width.
#
# Line Splitting options
#
code_width 80
# Unsigned Number
# Try to limit code width to N number of columns
ls_for_split_full True
# { False, True }
# Whether to fully split long 'for' statements at semi-colons.
ls_func_split_full True
# { False, True }
# Whether to fully split long function protos/calls at commas.
ls_code_width True
# { False, True }
# Whether to split lines as close to code_width as possible and ignore some groupings.
Related
I need to strip NULL's from the incoming message so I can forward it back out to another host. Syslog-ng does not forward messages properly that have any nulls in it. I've tried the following but cannot figure out how to target the NULL in the strings. With the below I still see the nulls in my local log and the remote system never see's the messages with nulls in it (not all messages have nulls and the ones that don't have nulls forward properly).
source s_ise {
udp(port(522));
};
destination d_ise {
file("/var/log/ise.log");
udp("myhost.example" port(516) spoof_source(no));
};
rewrite r_ise {
# remove nulls, or it won't forward properly
subst("\x00", "", type("string"), value("MESSAGE"), flags(substring, global));
};
log {
source(s_ise);
filter(f_ise_aaa);
rewrite(r_ise);
destination(d_ise);
};
NULLs are considered as string terminators.
Fortunately, the UDP source does not rely on line endings (newline characters or NULLs), so you can remove all unnecessary 0 bytes before parsing, for example:
source s_ise {
udp(port(522) flags(no-parse));
};
rewrite r_remove_nulls {
subst('\x00', '', value("MESSAGE"), type(pcre), flags(global)); # single quotes!
};
parser p_syslog {
syslog-parser();
};
destination d_ise {
file("/var/log/ise.log");
udp("myhost.example" port(516) spoof_source(no));
};
log {
source(s_ise);
rewrite(r_remove_nulls);
parser(p_syslog);
filter(f_ise_aaa);
destination(d_ise);
};
Alternatively, you can keep NULL bytes, but in that case, you should not use syslog-ng config objects that treat the message as strings (for example, parsers, string-based rewrite rules, string filters, etc).
I have a list of module names, as Strs, extracted from the META6.json. Specifically, the depends array. This contains the following entries:
"Config::Parser::toml:ver<1.0.1+>",
"Config:api<1>:ver<1.3.5+>",
"Dist::Helper:ver<0.21.0+>",
"Hash::Merge",
"Terminal::Getpass:ver<0.0.5+>",
How can I best match individual entries? Doing eq string matches isn't specific enough, as Config wouldn't match Config:api<1>:ver<1.3.5+> as a string. Trying to match using .starts-with also wouldn't work correctly, as Config:ver<1.3.5> wouldn't match Config:api<1>:ver<1.3.5>.
use Zef::Distribution::DependencySpecification;
my $spec-ver-all = Zef::Distribution::DependencySpecification.new("Foo::Bar");
my $spec-ver-zero = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<0>");
my $spec-ver-one = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1>");
my $spec-ver-oneplus = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1+>");
my $spec-ver-two = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<2>");
my $spec-ver-three = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<3>");
say $spec-ver-one.spec-matcher($spec-ver-all); # True
say $spec-ver-one.spec-matcher($spec-ver-two); # False
say $spec-ver-zero.spec-matcher($spec-ver-oneplus); # False
say $spec-ver-oneplus.spec-matcher($spec-ver-oneplus); # True
say $spec-ver-three.spec-matcher($spec-ver-oneplus); # True
I'm trying the following:
https://jsfiddle.net/zgaxy70t/1/
However it looks like the settings aren't being honored. How can I configure max file size, max # files, and file types within my call to unsigned_cloudinary_upload?
$('.upload_field').unsigned_cloudinary_upload(preset_name, {
cloud_name: 'cloudname',
disableImageResize: false,
imageMaxWidth: 2000, // 800 is an example value
imageMaxHeight: 2000, // 600 is an example value
maxFileSize: 8000000, // 20MB is an example value
//loadImageMaxFileSize: 200000, // default is 10MB
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|bmp|ico)$/i
}, {
multiple: true
})
I also tried this:
//{
// cloud_name: 'test',
// max_files: settings.maxFiles,
// tags: tags,
// client_allowed_formats: ["png", "gif", "jpeg", "jpg", "jpe", "jpc", "jp2", "j2k", "wdp", "jxr", "hdp", "webp", "bmp", "tif", "tiff", "ico", "ps", "ept", "eps", "eps3", "psd", "svg", "ai", "djvu", "flif", "tga"],
// max_file_size: 8000000
//},
Currently, it's not possible to use the unsigned_cloudinary_upload method and limiting client allowed formats, max files, max file size.
A close workaround will be to use the cloudinary_fileupload method to have the upload unsigned. This will allow you to set the max file size, and use a regular expression to limit the file type.
An example for using maxFileSize , and acceptFileTypes would look like the below:
$('.cloudinary-fileupload').cloudinary_fileupload({maxFileSize:100000000,acceptFileTypes: /(.|\/)(gif|jpe?g|png|bmp|ico)$/i});
Is there one? They both yield the same string
given 'file.txt'.IO -> $io {
say $io."$_" for <path abspath absolute>
}
# file.txt
# /Users/Me/file.txt
# /Users/Me/file.txt
The method Path::IO::absolute got a multi candidate that accepts a prefix to be glued in-between the current work dir and the filename or path fragment provided as a Path::IO instance.
dd 'file.txt'.IO.absolute('foo');
OUTPUT«"/home/camelia/foo/file.txt"»
So this is my function which is meant to read the lines of text from a file.
This is extracted from a larger program hence some of the comments may seem out of place. Anyways I need to use the functions text and file_lines in numerous other functions but even after declaring them as global I still get the UnboundLocalError: local variable 'file_lines' referenced before assignment error and I don't know what to do.
import sys
text = []
case = ''
file_lines = []
def read_file(file): # function to read a file and split it into lines
global text #sets variable text as a global variable for use in multiple locations
global case #handles case sensitivity.
try: #tests the statement after colon
open(file)
except:
print('oops no file found bearing that name')
else:
while file == '': #if the file name is blank print error, this prevents program from crashing
print ('error')
filename = input('enter a file and its extension ie file.ext\n>>')
with open(file) as f : #opens filewith name
text = f.read() #read all lines of program text.
print ("file successfully read")
print('TEXT SENSITIVITY TURNED ON !!!!!!')
text = text.split('\n')# breaks lines in file into list instead of using ".readlines"
# so that the program doesn't count blank lines
case == True
global file_lines
file_lines = text
a function that tries to use the read_lines variable would be
def find_words(words):
line_num = 0 # to count the line number
number_of_word = 0
if case == False:
words = words.lower()
file_lines = [file_lines.lower() for file_lines in text]
while "" in file_lines:
file_lines.remove('')
for lines in file_lines:
line_num += 1
if words in lines: #checks each for the words being looks for
print(line_num,"...", text[line_num-1])
number_of_word = 1
if number_of_word == 0: #to check if the word is located in the file
print('Words not found')
In your function find_words you forgot to specify that find_lines is global. Try
def find_words(words):
global file_lines
line_num = 0 # to count the line number
The function errors because file_lines is not defined within the scope of find_words otherwise.