(1) The accused person may before pleading apply to the judge to quash the indictment on the ground that it is calculated to prejudice or embarrass him in his defence to the charge, or that it is formally defective.(2) Upon such application the judge may quash the indictment, or may order it to be amended in such manner as he thinks just, or may refuse the application.(3) If at any stage of the trial it appears to the judge that there is any defect in the indictment, and the judge does not see fit to amend it, he may quash the indictment, or may leave the objection to be taken in arrest of judgment.(4) If an indictment is quashed under the provisions of this section, the accused person is entitled to be discharged from any further proceedings thereon, but he may be again indicted upon a fresh indictment, subject to the limitation, if any, as to the time within which a prosecution must be instituted.